views:

22

answers:

0

Hello, I'm getting some strange rewriting going on and was curious if anyone could shed some light. It's basically a pretty urls scenario, redirecting non existent path structure to a php script. The one difference is it checks for an existing file first:

RewriteEngine On
RewriteBase /test/

# if path begins in 'a' dir, & not a file, redirect to 'test.txt' in this dir 
RewriteCond %{REQUEST_URI} a
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*)    $1test.txt

# If test.txt does not exist, redirect to php script
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*)    index.php?path=$1    [L]

index.php is simply:

var_dump($_GET['path']);

I try hitting this directory with http://localhost/test/a/b/c/d/e/
The result I would expect is:

"a/b/c/d/e/test.txt"

However, I get:

"a/b/c/d/e/test.txt/d/e/"

The repeated path fragment on the end corresponds to the value of server variable PATH_INFO. And interestingly it is related to what physical directories exist - for example above I have created "a" & "b" nested folders but not "c","d"&"e".

Any idea what is going on there?