mod_rewrite, query_string, is replacing & with &, it's a problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 "&", 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 "&".

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&color=blue

So 'dog' has been turned to 'cat' in the query string, good. But all of the "&" have also been turned to "&". 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@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux