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?

j0k
  • 1,346
  • 12
  • 19

1 Answers1

0

Try this:

RewriteCond %{QUERY_STRING} cm_mmc=(.*)citizenhawk
RewriteRule ^.* /rrs? [R=permanent]
j0k
  • 1,346
  • 12
  • 19
  • 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. – modrewriteNewbie Aug 29 '12 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 '12 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 '12 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. – modrewriteNewbie Aug 29 '12 at 19:16
  • Great! If my suggestion works, then try RewriteRule ^.* /rrs/$1? [R=permanent]. – galeksic Aug 29 '12 at 19:26
  • WooHoo....worked great :) thanks a ton. Sorry to be such a pain but what does[R=permanent] mean? – modrewriteNewbie Aug 29 '12 at 20:02
  • [R=permanent] is for Redirect Permanent. Same as a 301, in fact. I've updated my answer with update from @galeksic – j0k Aug 29 '12 at 20:30
  • Code works like a charm. Thanks for the explanation :) – modrewriteNewbie Aug 30 '12 at 18:25