atom feed6 messages in ru.sysoev.nginxRe: capture rewrite for every after q...
FromSent OnAttachments
tokenNov 30, 2011 9:05 am 
António P. P. AlmeidaNov 30, 2011 9:12 am 
tokenNov 30, 2011 9:18 am 
António P. P. AlmeidaNov 30, 2011 9:46 am 
tokenNov 30, 2011 9:51 am 
tokenNov 30, 2011 10:12 am 
Subject:Re: capture rewrite for every after question mark
From:token (ngin@nginx.us)
Date:Nov 30, 2011 9:18:16 am
List:ru.sysoev.nginx

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.

if ($request_uri ~* ^(/home(/index)?|/index(.php)?)/?$) { rewrite ^(.*)$ / permanent; }

GET http://www.example.com/index.php 301 Moved Permanently GET http://www.example.com/ 200 OK

--------------------------------------- above works as expected.

But, now if i have the following results as 200 OK as expected.

http://www.example.com/index.php?randomvalue 200 OK

So how do you rewrite that if there is a question mark and or value that follows "/index.php?" then returns 301.

GET http://www.example.com/index.php?randomvalue 301 Moved Permanently

GET http://www.example.com/ 200 OK

Try:

location = /index.php { return 301 /; }

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,219385,219388#msg-219388