How to address spaces '%20'

Oh, the strange things mod_rewrite does!

How to address spaces '%20'

Postby worleyjbird » Tue Aug 26, 2008 3:07 pm

I'm trying to do a redirect but mod_rewrite doesn't seem to recognize the tag that represents a space -> '%20'

I should also mention that I tried ' ' but wasn't to get that too work either.
Here is what I'm doing, notice the space on the rewrite rule between 'Item' and 'one'.
Code: Select all
RewriteCond %{QUERY_STRING} ^page=/downloads/items/item_1/$ [NC]
RewriteRule ^.*$ /search/?q=Item One [R=301,L,NC]


Is there a workaround to this?

I got a little closer by adding '\?'. The results are technically correct but it displays itself in UI as 'Item?One':
Code: Select all
RewriteCond %{QUERY_STRING} ^page=/downloads/items/item_1/$ [NC]
RewriteRule ^.*$ /search/?q=Item\?One [R=301,L,NC]
worleyjbird
 
Posts: 8
Joined: Mon May 19, 2008 2:01 pm

Solved!

Postby worleyjbird » Wed Aug 27, 2008 8:56 am

Using '+' did the trick for me:
Code: Select all
RewriteCond %{QUERY_STRING} ^page=/downloads/items/item_1/$ [NC]
RewriteRule ^.*$ /search/?q=Item+One [R=301,L,NC]


So simple but so trivial! I could not find any documentation on this but fortunately a colleague knew about the +. Hope this helps someone else.
worleyjbird
 
Posts: 8
Joined: Mon May 19, 2008 2:01 pm

Postby richardk » Fri Aug 29, 2008 7:13 am

You should also be able to use "\ ".
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Idiosyncrasies

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron