Clean URLS with mod rewrite and URL Encoded characters causes 404?

Posted by Richard JP Le Guen on Server Fault See other posts from Server Fault or by Richard JP Le Guen
Published on 2010-06-03T17:16:23Z Indexed on 2010/06/03 17:26 UTC
Read the original article Hit count: 287

I have a web site using mod_rewrite to get some clean urls and custom 404 pages. My .htaccess file looks like this:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?clean_url=$1 [QSA,L]
</IfModule>

What puzzles me is that if the URL contains a %2F (url-encoded /) the server seems to force a 404. As an example, http://example.com/category/article would be a normal article, but then http://example.com/category%2farticle gives a server-generated 404 page. (not the custom 404 page)

I wouldn't have expected this... why this is happening? Is there a way around it?

© Server Fault or respective owner

Related posts about mod-rewrite

Related posts about .htaccess