Forum Moderators: phranque

Message Too Old, No Replies

RewriteMap and URL with spaces issue

         

da644

9:35 am on Jul 19, 2007 (gmt 0)

10+ Year Member



Hi.

We have a RewriteMap configured and working fine, however we need to add a URL to the map that contains a space. I have tried several different things, but none of them work. What I have in the map file is:

trains.shtml/title/Trains Outbound/section/General trains/outbound

Obviously it can't be a space as the space is the field delimiter, I have tried replacing the space with %20 and . (dot) and adding a \ before the space but none of them worked.

The rewrite conditions and rules are:

RewriteMap theMap txt:/tmp/theMap.txt
RewriteCond ${theMap:$1¦NotFound}!NotFound
RewriteRule ^/(.*) ${theMap:$1} [R=301,L]

How do you escape a space in the map file?

Thanks in advance for any help.

Kind regards,

Andrew

g1smd

12:36 pm on Jul 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This is another reason to avoid spaces in URLs.

I would change the space in the URL itself to be a hyphen or a dot or a comma (but NOT an underscore).

As you know, a space gets encoded as %20 - otherwise how could you tell where the end of a URL was?

URLs with spaces in them soon%20become%20very%20hard%20to%20read.

jdMorgan

2:42 pm on Jul 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd suggest preceding the call to the RewriteMap with a one-off RewriteRule to change the space in that one URL-path to some other character. Then call the RewriteMap with that modified URL.

Alternatively, just do a direct redirect for that one particular URL-path.

Jim