capture rewrite for every after question mark
António P. P. Almeida
appa at perusio.net
Wed Nov 30 17:46:34 UTC 2011
On 30 Nov 2011 17h19 WET, nginx-forum at nginx.us wrote:
> Thanks for suggestion appa, i apply what said to try and results in
> a "Redirection Loop".
>
>> Hello,
>>
>> I have found the following while searching it is the only one i can
>> get working with my config setup
>> to send a 301 permanently if "/index.php" is directly accessed.
Remove/comment out the if below and try:
http {
map $redirect_direct_access $request_uri {
default 0;
~/index(\.php)? 1;
~/home(/index)? 1;
}
}
server {
server_name www.example.com;
root /path/to/root;
location / {
if ($redirect_direct_access) {
return 301 /;
}
}
}
> if ($request_uri ~* ^(/home(/index)?|/index(.php)?)/?$)
> {
> rewrite ^(.*)$ / permanent;
> }
--- appa
More information about the nginx
mailing list