Escaping characters in a mod rewrite rule?

Escaping characters in a mod rewrite rule?

Posted by: ncasares
Posted on: 2007-05-14 16:07:00

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!

Re: Escaping characters in a mod rewrite rule?

Posted by: Atropos7
Posted on: 2007-05-14 17:17:00

In reply to:

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.


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 -//-

Re: Escaping characters in a mod rewrite rule?

Posted by: seiler
Posted on: 2007-05-14 17:23:00

Should utm_conent be utm_content?

Re: Escaping characters in a mod rewrite rule?

Posted by: ncasares
Posted on: 2007-05-14 22:20:00

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?

Tags: rewrite rulemod rewritehtaccess filerewriteruleutmrewrite rulemod rewritehtaccess filerewriteruleutm