How to stop apache from doing url decoding?

Posted by mrzippy, 04-20-2009, 03:12 PM
Hello, I have an interesting problem.. there is a customer who transferred their site over to our servers and has run into some kind of encoding issue. They have file on their website named: EXCL%204810_00%20BeefSkewers.jpg You can see that the "%20" characters are actually part of the file name on the server. So the problem is that when they try to call the image in a URL: http://www.domain.com/rimages/EXCL%204810_00%20BeefSkewers.jpg It gives a 404 not found error. We use apache 2.2.x on our servers, and my admins are stuck on how to fix this. Any suggestions? (Besides renaming the files. The problem is that this issue appears to also effect other text in their database that uses various symbols, such as the ", ', and the degree (for temperature) sign...) Thanks. Last edited by mrzippy; 04-20-2009 at 03:15 PM.

Posted by ramnet, 04-20-2009, 08:46 PM
There is no way to fix this because the encoding is done to satisfy the RFC papers that dictate that a URI cannot contain particular characters (such as space, ?, etc) In your specific case, what you should do is decode the file name itself and that would fix everything. In your case you would replace %20 with a space. Then if you refer to the file using %20 or not it will work. Basically rename "EXCL%204810_00%20BeefSkewers.jpg" to "EXCL 4810_00 BeefSkewers.jpg" on the file system side.

Posted by hiabhilash, 04-21-2009, 02:59 AM
mrzippy, try using "AllowEncodedSlashes" directive. Good luck!

Posted by dexxtreme, 04-21-2009, 04:43 PM
The best solution would be to not have filenames that use characters that have "special" meanings, such as commas, apostrophes, percent signs, ampersands, slashes, plus signs, etc. Filenames should really be limited to alphanumerics, dashes, underscores, periods, and maybe a couple other characters. (Even spaces can cause issues, namely being remapped into %20 entries.) That would be the only way to guarantee that all OS'es, scripts, and filesystems have little to no problems managing the files.

Ця відповідь Вам допомогла?

 Роздрукувати цю статтю

Також прочитайте

how to do this with a cronjob?

Posted by HD Fanatic, 07-13-2007, 04:18 PMI want to copy a sql file from my secondary hdd to my...

Box Overloading

Posted by SuperHosterz, 01-13-2008, 11:56 AMI've 50 sites hosted on server all are small sites,...

APC storage location in debian

Posted by Owdy, 03-05-2010, 11:36 AMWhere APC stores its cache files in debian?

Urgent problem: too much traffic, how to stop it?

Posted by fgalli, 05-04-2007, 09:33 AMHi, i've a vps with iptables, but i've too much traffic...

How can I redirect all traffic which is NOT on a mobile device?

Posted by Chris`, 01-06-2008, 07:44 AMHey WHT! I have another question. I've finally got a...