Escaping characters in a mod rewrite rule?


#1

I’ve got a fairly basic rule setup in my .htaccess file, but for some reason, I cannot get this to work. What I have:

RewriteRule ^index.php?utm_source=crm&utm_medium=email&utm_conent=generic01$ http://www.webassetvault.com [R=301,L]

For some reason this rule isn’t working. If I remove the query string from the original URL I can get it to work (even with the question mark). When I re-introduce the query string the rule stops working and no redirection happens.

Anyone have any clue what’s going on? Am I correct in thinking that the “.” and “?” must be escaped?

Thanks in advance for your replies!


#2

You can’t match a query string in the RewriteRule directive. You must match it in a RewriteCond directive instead.RewriteCond %{QUERY_STRING} utm_source=crm&utm_medium=email&utm_conent=generic01 RewriteRule ^index\.php$ http://www.webassetvault.com/ [R=301,L]
:cool: openvein.org -//- One-time [color=#6600CC]$50.00 discount[/color] on [color=#0000CC]DreamHost[/color] plans: Use ATROPOS7


#3

Should utm_conent be utm_content?


:stuck_out_tongue: Save up to $96 at Dreamhost with ALMOST97 promo code (I get $1).
Or save $97 with THEFULL97.


#4

Thank you both for the responses. Yes, it should be “content” and not “conent”. : )

Atropos7, I followed your directions and it (almost) worked! I’m using the .htaccess file in a subdomain and it seems like that’s causing a problem. Is there something I need to do differently to make this work on a subdomain?