开发者

Something rewrites rules for php when Apache mod_rewrite module is disabled

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 Apac开发者_高级运维he 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).


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜