New answers tagged

0

You can do this by following:- <Files *test.pdf> Order allow,deny Deny from all </Files> <Files *test.txt> Order allow,deny Deny from all </Files>


0

Nope. https://stackoverflow.com/questions/4930914/prevent-pdf-file-from-downloading-and-printing Ultimately you will need to: Create Images for each page Present those to the user on the web via your own interface (html, flash etc)


0

You can specify IP address from you want access the files or if you have login then use particular email ID to allow viewing. All this you can specify at start of your load_pdf.php


0

Solution for rewrite location /search { rewrite ^/search/(.*)/page/(.*)?$ /index.php?search=$1&page=$2 last; rewrite ^/search/(.*) /index.php?search=$1 last; try_files $uri $uri/ /index.php; } location /p/all_articles { rewrite ^/p/all_articles/user/(.*)/page(?:/([0-9]+))?$ /index.php?p=all_articles&user=$1&page=$2 last; rewrite ^/p/...


2

You might be interested in the questions with the rewrite tag, since it contains many variations of your problem. Your Apache rewrite rule: RewriteRule ^(.*)$ /index.php/$1 [L] appends the entire request URI to /index.php. In nginx the path of the URI (normalized) is available in the $uri variable. If you need the query arguments too, you can use the $...


1

On Apache 2.4+ you can try putting the whole block of directives in an <If> block using an Apache Expression that tests the requested hostname. For example: <If "%{HTTP_HOST} == 'www-static.example.com'"> # : # Directives go here... # : </If> A few notes on your existing directives: <IfModule mod_headers.c> Header unset ETag ...


1

Try the following instead: RewriteCond %{QUERY_STRING} ^trx_id=([^&]*) RewriteRule (.*) /$1%1 [QSD,R,L] The RewriteRule pattern matches against the URL-path only. To match the query string you need a condition that checks against the QUERY_STRING server variable. %1 (as opposed to $1) is a backreference to the preceding CondPattern (ie. the value of ...


3

The nginx rewrite directive is applied unconditionally, whereas you have many conditions in your rewrite rules. Use the try_files directive instead: location = /index.php { # PHP options } location / { try_files /public$uri /public$uri/ /index.php?route=$uri; }


0

RewriteCond %{ENV:HTTP_CDN_LOOP} !cloudflare [NC,OR] RewriteCond %{ENV:HTTP_CDN_LOOP} !^$ By checking that the variable does not contain "cloudflare" OR is not empty then it will always be blocked because when it does contain "cloudflare" it's not empty! (2nd condition is successful and the rule is processed.) The only way to check that an env var exists ...


0

You have two main issues.... Your directives are in the wrong order in the .htaccess file. Your HTTP to HTTPS and www canonical redirects need to go before your front-controller that routes the URL to your CMS. Hence the incorrect external redirect to /index.php?url=courses/acme-course.php - exposing your internal CMS URL structure. The removal of .php is ...


1

The apache.conf has the apache rewrites written above apache.conf would seem to be your "server config". When mod_rewrite directives are used in a server context, as opposed to a directory (.htaccess) context they work differently and can require a different syntax. This explains why you needed to prefix the substitution string with a slash in order to make ...


1

Reqhost was set to: "www.example.com:443" That would certainly seem to be the cause of the problem. Although why the port (the request is being sent on) is now present in the Host header is another matter. 443 is the default port for HTTPS. However, since it is the default port, it does not need to be be present in the Host header. You would only need the ...


1

If you want HTTPS enabled for all URIs, then keep it simple like this: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] The condition is: If https is not enabled. And the rewrite rule is match anything in the uri and send it to its https counterpart.


1

This looks like the condition is not matching the request you are trying to re-route to HTTPS: RewriteEngine On RewriteCond %{REQUEST_FILENAME}.php -f RewriteCond %{REQUEST_URI} !/$ RewriteRule (.*) $1\.php [L] ErrorDocument 404 https://example.com/404.php Options -Indexes From the docs: https://httpd.apache.org/docs/current/mod/mod_rewrite.html The ...


1

It's not clear why your redirect is not working (assuming you already have other directives in your .htaccess file that are working). Maybe you have a conflict with other directives. However, if you want to block access to these .txt files then you don't want to redirect the request, so RedirectMatch is not the correct tool for the job. Simply block access ...


0

I would prefer to have example.com/<almost anything> to go to example.com/v1.1/ and example.com/debug/<anything> to go to example.com/v1.2/ Yes, this would certainly be preferable. (Also consider using a debug subdomain instead and keep the same URL-path for the "live" and "debug" versions.) Try the following instead: # Rewrite the "live" ...


1

You can achieve this behaviour without any RewriteRules by using symbolic links. If your DocumentRoot points to /var/www/html, you could move your versioned directories v1.1 and v2.2 to /var/www root@www:/var/www# ls -l total 0 drwxrwsr-x 1 www-data www-data 512 Dec 28 12:30 v1.1 drwxrwsr-x 1 www-data www-data 512 Dec 28 12:31 v1.2 and symlink v1.1 to html ...


0

You can add following to your vhost file To deny specific files access <Files *.bat> Order allow,deny Deny from all </Files> You can add your extension type according to your requirements.


0

The regular expression you have should work. You should be able to also delete action.bat| and it should function the same. If your file does not end with .bat, that might be causing issues. A simplified explanation of what it does: \.(htaccess|htpasswd|ini|log|sh|inc|bak|md|txt|lock|phar|bat)$ ||| | ...


Top 50 recent answers are included