apache - RewriteRule - matching exact URLs with and without querystrings -


i have list of old urls being mapped equivalent new url. of old urls include querystrings not.

there's no set pattern mapping, can't use wildcard rules, need make exact matches.

i've been trying approach:

rewriterule ^products/index\.cfm\?pagename=products/index$ /test1/ [r=301,qsd,l,nc] rewriterule ^products/index\.cfm$ /test2/ [r=301,qsd,l,nc] 

however, if go http://example.com/products/index.cfm?pagename=products/index it's getting matched in second rule, , redirected http://example.com/test2/

thanks,

jt

you can't match against query string in rewrite rule's pattern. need match against %{query_string} variable:

rewritecond %{query_string} ^pagename=products/index$ [nc] rewriterule ^products/index\.cfm$ /test1/ [r=301,l,nc]  rewritecond %{query_string} ^$ [nc] rewriterule ^products/index\.cfm$ /test2/ [r=301,l,nc] 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -