Click to See Complete Forum and Search --> : Apache mod_rewrite is automatically decoding URLs


auxone
10-29-2009, 07:11 PM
Hi,
I'm using mod_rewrite for "clean URLs". I've noticed that when passing an encoded URL, mod_rewrite automatically decodes it before passing it onto my script.

This is completely unwanted behavior because my script parses the "/" in the clean URL so after decoding it can't tell the different between a real "/" and a %2F.

Does anyone know of a quick fix? I've tried various filters on the Rewrite like B and NE. I don't want to resort to modifying the mod_rewrite module itself and recompiling Apache, and double encoding slashes is not prefered.

Thanks in advance.

(Furthermore, mod_rewrite likes to decode %20 into a + which I hate.)

opifex
10-29-2009, 08:29 PM
Apache mod_rewrite is automatically decoding URLs
It's only doing what you are telling it to do. It would appear that you might need to visit your code and file/url naming practices. It is NOT a good idea to use "spaces" in file names or url's to start with. As far as parsing the "/"? That one confuses me.

auxone
10-29-2009, 08:39 PM
Thanks for the reply. I've decided to parse the "/" in the actual mod_rewrite, when I *can* tell the difference between %2F and / (presumably).

I have the following:
RewriteRule ^(.*)/(.*)/(.*)/(.*)$ index.php?q1=$1&q2=$2&q3=$3&q4=$4

but it only works if there are exactly 4 slashes in the URL. Anyone know how to make it parse "from 0 to 4"? I'm a bit stumped.

Thanks again.