Embedded & in URL and interaction with rewrite

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


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-20-2006
Jim Hayter
 
Posts: n/a
Default Embedded & in URL and interaction with rewrite

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
  #2 (permalink)  
Old 03-20-2006
Robert Ionescu
 
Posts: n/a
Default Re: Embedded & in URL and interaction with rewrite

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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:42 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0