I have the setup below; a very simple URL rewrite setup with a test setup
// ----- test.php -----
<?php
phpinfo();
// ----- test.php -----
The config for test.local is as below.
<VirtualHost *:80>
ServerName test
ServerAlias test.*
DocumentRoot /var/www/test
</VirtualHost>
<Directory "/var/www/test/">
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* test.php/$0 [R,NE]
</Directory>
Now if I make a request GET http://test.local/my-path-info
the default phpinfo()
page appears as expected, if I add slash in the path info, that works too. But if I add an encoded forward slash %2F
into the URL (example GET http://test.local/my-path-info%2fsomething-else
), it comes up as 404 Not found
. Basically it doesn't get to the php file.
Any idea why this is happening, and how to get around it?
The setup is on Apache 2.2.13, PHP 5.3.8 on Linux (Centos 5.x).
NOTE: What I am trying to do here is to add a forward slash into one of the path-info components, such that it doesn't get interpreted by the router logic in an MVC framework. Without encoding it, the router cannot differentiate between a slash that is a path separator and the one that is part of a path component.