This is a discussion on Embedded & in URL and interaction with rewrite within the Apache Web Server forums, part of the Web Server and Related Forums category; Apache 1.33 on Solaris 10. I have a rewrite rule that takes http://<hostname>/countrybrowse_<countryname&...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Apache 1.33 on Solaris 10.
I have a rewrite rule that takes http://<hostname>/countrybrowse_<countryname> and rewrites it to /cgi/countrybrowse.pl?country=<countryname>. Unfortunately, this does not work as desired if the countryname contains an ampersand. http://<hostname>/countrybrowse_Antigua%20%26%20Barbuda becomes /cgi/countrybrowse.pl?country=Antigua & Barbuda. This query string is not parsed as desired. http://<hostname>/countrybrowse.pl?country=Antigua%20%26%20Barbuda is parsed correctly. I turned on logging and see that the string %20%26%20 is unencoded before the rewrite rules are applied. I'd like to avoid a duplicate set of rules that test for the existence of ' & ' in the original URL and parse it differently. Is there a way to handle this so the result of the rewrite is /cgi/countrybrowse.pl?country=Antigua%20%26%20Barbuda? Is that what I want? Thanks, Jim |
|
|||
|
Jim Hayter wrote:
> Is there a way to handle this so the result of the rewrite is > /cgi/countrybrowse.pl?country=Antigua%20%26%20Barbuda? Is that what I > want? Double encoding. %25%26 The '&' is a valid character in the URL, so it isn't escaped again in the substitution. Another way is that you analyze the full ENV QUERY_STRING (country=Antigua & Barbuda) in your script but not just the variable "country". You might also write a RewriteMap for ampersand escaping. -- Robert |