httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Rochkind <rochk...@jhu.edu>
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:

/foo?animal=dog&color=blue

What I get out of this is:

/foo?animal=cat&amp;color=blue

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.

Jonathan

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message