You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Sven Köhler <sk...@upb.de> on 2008/06/28 21:42:28 UTC

[users@httpd] How to properly build querystring in RewriteRule

Hi,

so i'd like to do the following:

If a Browser sends a request to "http://anyname.myserver.de" then i'd 
like to redirect the browser to
   http://www.myserver.de/domain=name=anyname.myserver.de

If course, if anyname is substituted by ??? or &&& or ===, i still want 
things to work properly - that is:
   chars like ?&= must be replaced by  % following two hex digits.

Here's what i've tried so far:


RewriteEngine On
RewriteMap mymap int:escape

1) RewriteRule ^/test
   http://www.myserver.de/domain?name=%{HTTP_HOST} [L,R=301]

2) RewriteRule ^/test
   http://www.myserver.de/domain?name=${mymap:%{HTTP_HOST}} [L,R=301]


So the escape-map used in 2) sucks. It doesn't escape & or = or ?
The rule 1) simply redirects to URLs such as
   http://www.myserver.de/domain?name=&&&
   http://www.myserver.de/domain?name=???
   http://www.myserver.de/domain?name====

URLs which i simply consider very harmful.


What's the apache-way of properly doing this?
I don't want to have an external program for doing the mapping. This is 
such a standard-task (building a properly escaped querystring) - there 
must be way.


I'm using apache 2.2.9 on Linux.


Regards,
   Sven