Apache:% 25 in url (400 Bad Request)

I have a url containing the following:

/somepath/morestuff/ohno%25foobar

For some reason, apache reports 400 bad requests (this relates to% 25). I use mod_rewrite to rewrite the path to point to my codeigniter instance, but it does not even get to codeigniter, this is just the apache error by default.

Any ideas?

+5
source share
3 answers

I suspect you are using PATH_INFOCodeIgniter to process requests. Therefore, your file .htaccesscontains a set of rules that looks something like this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php/$0 [L]

mod_rewrite URL-, , %25 %. , backreference somepath/morestuff/ohno%foobar, . Apache , % /index.php/somepath/morestuff/ohno%foobar , .

Apache 2.2, mod_rewrite B , , URL. :

RewriteRule ^.*$ index.php/$0 [B,L]

escape RewriteMap, Apache mod_rewrite, , , , , . , .

/ :

RewriteMap escape int:escape

, :

RewriteRule ^.*$ index.php/${escape:$0} [L]

, CodeIgniter PATH_INFO , REQUEST_URI , mod_rewrite ( ). , CodeIgniter AUTO ( , ), URL , .

+11

In jquery, before setting up the url you need to encode how it will encode% and / both ..... " encodeURI (encodeURI (encodeURIComponent ('your string'))); "

on the php or view page you should decode as follows

urldecode (urldecode (htmlspecialchars ('your encoded string', ENT_QUOTES)))

+1
source

All Articles