New answers tagged

1

Isn't the .php after %{REQUEST_FILENAME} redundant? The variable should already contain the .php, right? Well, yes and no, it depends what you are trying to do. RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^ %{REQUEST_FILENAME}.php [L] This rule allows you to request extensionless URLs. eg. /index or /foo and this internally rewrites the request to /...


0

The only solution that was working for me, is: AddOutputFilterByType INFLATE;SUBSTITUTE;DEFLATE text/html Source: https://phabricator.wikimedia.org/T282613 https://gitpull.it/T776


1

Should I escape the slash / in RewriteCond? By "escape the slash", you really mean "should I match a URL encoded slash or not?". This depends entirely on the HTTP request being made to your server. But I check https://serverfault.com/a/968916/280923 and it said "The slash (/) does not need to be escaped". So I am confused. ...


0

You can use referrers (http://nginx.org/en/docs/http/ngx_http_referer_module.html#valid_referers) valid_referers none blocked server_names docs.google.com; Than you can just use $invalid_referer variable in your location block. if ($invalid_referer) { rewrite /wp-content/uploads/(.*)$ /dl-file.php?file=$1; }


0

You can't do this with .htaccess alone since the file-path you are wanting to "rewrite" to is outside of the domains DocumentRoot. In .htaccess (a directory context), the substitution string represents a URL-path, not a file-path. You can do this if you have access to the server config (virtualhost). In a server or virtualhost context you can ...


1

You can do it like this using mod_rewrite: RewriteEngine On RewriteCond %{QUERY_STRING) !(^|&)year=[^&]+ RewriteRule ^/?my-page\.html$ https://www.my-2nd-host.com/current-year/my-page.html [R=302,L] The regex (^|&)year=[^&]+ checks for the presence of the year URL parameter with a non-empty value. The ! prefix then negates the expression so ...


Top 50 recent answers are included