views:

38

answers:

2

I run the following url:

http://localsite/index.php/foo/bar

index.php is executed and outputs variable:

$_SERVER[SCRIPT_FILENAME] = E:/path/to/file/index.php

mod_rewrite in Apache is disabled.

Who rewrites the rule?
Or what happens?

How index.php is found? Why apache decided to run it?

My configuration: Windows Vista, Apache Apache/2.2.14 (Win32) PHP/5.3.1 (with php module).

(Indeed the problem is the rule is actually rewritten before mod_rewrite - this is when mod_rewrite is enabled. This causes that RewriteCond %{REQUEST_FILENAME} !-f is always false, because /foo/bar is trimmed before RewriteCond).

+3  A: 

This is caused by the AcceptPathInfo Apache directive.

It treats everything up to

http://localsite/index.php

as the resource, and puts

/foo/bar

into the $_SERVER["PATH_INFO"] variable.

It's sometimes used as a poor man's URL rewriter when mod_rewrite isn't available - with the downside that in a normal configuration, there has to be a .php somewhere in the URL.

Your options are to turn this off, or to use a different URL - depending on your situation.

Pekka
It was really difficult for me to realize that something else is rewriting urls also. Thanks!
sergdev
It's not a rewrite - you had an incorrect understanding of how URLs are parsed. For more info, see Section 3.2 in http://www.rfc-editor.org/rfc/rfc3875.txt
Andrew Medico
A: 

Maybe you should use $_SERVER[REQUEST_URI] instead, afaik, SCRIPT_FILENAME tells you which file php was started with.

MattSmith