Welcome! Log In Create A New Profile

Advanced

Re: capture rewrite for every after question mark

November 30, 2011 01:12PM
token 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.
> >
> >
> > 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 /;
> > }
>
> Update,
>
> I am using
>
> if ($request_uri ~* ^/index.php(.*)$){
> rewrite ^(.*)$ / permanent;
> }
>
> The above resuls as which dose the 301
> moved permanently with the exception of retaining
> the the question and the the value.
>
> I guess from a search engines point of view its
> see's the 301 Moved Permanently so in that case it
> ok, but it would be nice to not retain the
> "?randomvalue".
>
>
> http://www.example.com/index.php?randomvalue 301
> Moved Permanently
> http://www.example.com/?randomvalue 200 OK


Final Update, Resolved

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

Seems to work now
Subject Author Posted

capture rewrite for every after question mark

token November 30, 2011 12:06PM

Re: capture rewrite for every after question mark

António P. P. Almeida November 30, 2011 12:14PM

Re: capture rewrite for every after question mark

token November 30, 2011 12:19PM

Re: capture rewrite for every after question mark

António P. P. Almeida November 30, 2011 12:48PM

Re: capture rewrite for every after question mark

token November 30, 2011 12:51PM

Re: capture rewrite for every after question mark

token November 30, 2011 01:12PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 323
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready