Forum Moderators: phranque

Message Too Old, No Replies

RewriteMap with blanks

Syntax for "unescape"

         

maggi

7:21 am on Jul 20, 2004 (gmt 0)

10+ Year Member



My goal is to accept blanks in url's in a RewriteMap as
RewriteRule ^/(.*)\.html$ /cgi?var=${rewritemap:$1 [L]
Content of RewriteMap is:
New-York 1234
New York 1234
New%20York 1234
New\ York 1234
The first example
[mysite.com...] works fine and I use it in handcoded url's.
My dynamic site generates url's from a database and therefore ocures a blank in the url:
[mysite.com...] York.html
Thats not correct and the interaction of Apache and the browser results in
[mysite.com...]
But RewriteMap is not able to translate a %20
or " ", even when I escape it to "\ " in New\ York.
I am using Apache/1.3.26
In RewriteGuide I found:
escape:
Translates special characters in the looked up key to hex-encodings.
unescape:
Translates hex-encodings in the looked up key back to special characters.

What is the syntax like when I want mod_rewrite to apply the "unescape" command to translate the hex-encoded "%20" back to " "? I tried
RewriteRule ^/(.*)\.html$ /cgi?var=${rewritemap:$1 [L,unescape] but thats like the standard behavior.
Thanks a lotMaggy

jdMorgan

3:30 pm on Jul 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maggi,

I've never tried anything like this, but I do note that the closing "}" around RewriteMap is missing in both of your examples. That may cause some of these problems.

As an alternative, would it be possible to alter your script to substitute "-" for " " when it outputs a URL? This would simplify the whole problem.

Jim

maggi

5:07 pm on Jul 20, 2004 (gmt 0)

10+ Year Member



Thanks for the missing "}", that was a mistake while shortening the string. Its working with a ending "}".

I am wondering about the syntax I found in:
[httpd.apache.org...]
RewriteMap lowercase int:tolower
RewriteMap vhost txt:/path/to/vhost.map
RewriteRule ^/(.*)$ %1/$1 [E=VHOST:${lowercase:%{HTTP_HOST}}]
I am familar in using txt:/path/to/map
but do I have to define the function "Rewritemap int:unescape" with
RewriteMap myunescape int:unescape
as an internal dummy definition (without a path as in
RewriteMap mylistfile txt:/path) and to use later on "myunescape" in the RewriteRule?

I found another example with an internal function:
[simon.incutio.com...]
RewriteEngine on
RewriteMap lowercase int:tolower
RewriteCond ${lowercase:%{SERVER_NAME}} ^([a-z-]+)\.staging\.mintchaos\.com$
RewriteRule ^(.*) /home/mintch/www/staging/%1/$1
And tried:
RewriteMap myunescape int:unescape
RewriteRule ^/(.*)\.html$ /cgi?var=${{myunescape}mylistfile:$1} [L]
The syntaxcheck is ok, but it is not working.
Thanks, Maggy