Spaces in redirect url.

Topics: User Forum
Oct 27, 2006 at 2:58 PM
OK, probably a silly question, but how would I redirect to a url with a space in it?

If I do something like

RewriteRule (.)changing(.)objId=287107(.*) http://newlocation/file with space.txt R

I get a "WARNING: Badly formed RewriteRule modifier flags." because it parses the modifier flag based on the space.

However, if I url encode the thing:
RewriteRule (.)changing(.)objId=287107(.*) http://newlocation/file%20with%20space.txt R

The url rewrite give me:
"GenerateReplacementString: Substring index out of range (%20)" and returns:

http://newlocation/file0with0space.txt

ideas?

TIA!

B.J.
Coordinator
Oct 27, 2006 at 6:55 PM
I don't know how you would do that in IIRF.
I am not sure it would work.

I will consider it a feature request. I will have to re-work the parsing of the RewriteRule line to handle substitution URLs that contain spaces.

-Cheeso

Oct 27, 2006 at 7:31 PM
Thanks for the feedback. I'll probably have to do it myself in the short term.

Thanks!

B.J.
Nov 16, 2006 at 8:40 PM
I am no C expert, but I did munge some code together to handle the case of spaces in the redirect pattern using apostraphes. I can make this code available, if desired. Just tell me how.

Thanks!

B.J.
Nov 17, 2006 at 2:37 PM
One work around I imagine could be done is to capture a space (\x20) from the original URL, then use $n to put it whereever you want in the substitution URL. Of course, that would rely on a space being in a predictable place in the original URL.