httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Rochkind <>
Subject [users@httpd] mod_rewrite, query_string, is replacing & with &amp;, it's a problem
Date Wed, 19 Sep 2007 20:55:37 GMT
So I am trying to use mod_rewrite to rewrite something in my query 
string.  Apache 2.2.3.

It appears that mod_rewrite or something else will rewrite all "&" in 
query string to "&amp;", whenever you do anything with the query string 
in mod_rewrite. Even with the [NE] flag. I'm not sure why it's doing 
this, and it's highly undesirable to me here, because the request ends 
up going to some software that is unhappy with the query string 
parameter delimiters being turned into "&amp;".

As an example, let's pretend I want to change 'dog' in the query string 
to 'cat'. I try:

RewriteEngine on
RewriteCond  %{query_string} ^(.*)dog(.*)$
RewriteRule   ^(.*)$   $1?%1cat%2  [NE,R,L]

Let's say the incoming URL is:


What I get out of this is:


So 'dog' has been turned to 'cat' in the query string, good. But all of 
the "&" have also been turned to "&amp;". This is a problem for me in my 
particular circumstances. I want apache to leave the query string alone 
except for what I specifically replace.

Is this a bug? Is this intended behavior?  Is there anything I can do 
about this?

Advice appreciated.


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message