Our website would like to use cookies to store information on your computer. You may delete and block all cookies from this site, but parts of the site will not work as a result. Find out more about how we use cookies.

Login or Register

Powered by
Powered by Novacaster
 
Re: mod_rewrite notes: Redirect based on URI and Query String
by Simon at 17:20 07/12/05 (Forum::Technical Advice::General)
RewriteCond %{QUERY_STRING} ^id=3209&n=[0-9]+$ [OR]
RewriteCond %{QUERY_STRING} ^id=3209$ [OR]
RewriteCond %{QUERY_STRING} ^n=[0-9]+&id=3209$
RewriteRule ^/showarticle.pl$ /index.pl?section=267&n=3621 [R=301,last]

This rewrites /showarticle.pl?[permuation of params] to /index.pl?[other params] as a Permanent Redirect (301), not Temporary (302), and uses [last] to terminate the rule checks immediately we have a match.

Worked out when I realised that you can't put the QUERY_STRING on the end of the URI in the RewriteRule - it has to be handled as a RewriteCond instead.

This may seem obvious to you as indeed it's now obvious to me too.
--
simon

<< Trivial, I thought. Wanted: Someone cleverer than ... >>
View Comments (Flat Mode) Printer Version
mod_rewrite notes Simon - 7/12
    Re: mod_rewrite notes: Redirec... Simon - 7/12
       Re: mod_rewrite notes: Redirec... Hugo van der Sanden - 8/12
          Re: mod_rewrite notes: Redirec... Simon - 8/12
             Re: mod_rewrite notes: Redirec... David Crowson - 8/12