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 ... >>
Powered by
Powered by Novacaster