1

I am very new to mod rewrite. I need to redirect any user with "citzenhawk" parameter in their url to my url

for example

http://www.mywebsite.com/?sc=CX12N003&cm_mmc=affiliate--citizenhawk--nooffer-_-na&prfc=5&clickid=0004c845fa9a87050a4277221a003262

should result into

http://www.mywebsite.com/

Here are my rewrite conditions:

RewriteCond %{QUERY_STRING} (&|^)cm_mmc=(.)citizenhawk(.)(&|$)$ 
RewriteRule ^/rrs/ [NC,R=302,L]

Where am I going wrong? Is my RewriteCond wrong?

1 Answer 1

0

Try this:

RewriteCond %{QUERY_STRING} cm_mmc=(.*)citizenhawk
RewriteRule ^.* /rrs? [R=permanent]
8
  • Thanks j0k for your response. I do not have any testing environment and do not wish to put this in production without testing. Is there any online tool available so i can test this condition? Thanks again for your help. Aug 29, 2012 at 18:39
  • If you a local computer with a running apache you can test it easily by create an index.php, a .htaccess (with the rules inside) and access index.php?sc=CX12N003&cm_mmc=affiliate--citizenhawk--nooffer-_-na&prfc=5&clickid=0004c845fa9a87050a4277221a003262
    – j0k
    Aug 29, 2012 at 18:48
  • I just tried on Windows7 Apache2.2.22 and it works if second line is RewriteRule ^.* /$1? [R=permanent].
    – galeksic
    Aug 29, 2012 at 19:09
  • Thanks a ton for your prompt answer. It works great :) except for one issue...i forgot to mention that when i get redirected to my website i would like to append url with rrs. For example if you type http://www.mywebsite.com/?sc=CX12N003&cm_mmc=affiliate--citizenhawk--nooffer-_-na&prfc=5&clickid=0004c845fa9a87050a4277221a003262, it should be redirected to http://www.mywebsite.com/rrs/ . sorry i forgot to mention this before. Aug 29, 2012 at 19:16
  • Great! If my suggestion works, then try RewriteRule ^.* /rrs/$1? [R=permanent].
    – galeksic
    Aug 29, 2012 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.