使用PHP内置服务器和Symfony 2请求任何路径时,$ _SERVER [' SCRIPT_NAME']是/index.html

时间:2015-05-07 22:42:16

标签: php symfony php-builtin-server

我有这种奇怪的行为,如果路径不包含句点(例如/ what-something / a-page),则$_SERVER变量SCRIPT_NAME将替换为index.html或index .php如果它们存在于根文件夹中。 SCRIPT_NAME是正确的值:/whatever.something/a-page,如果根文件夹中没有index.html或index.php。

我检查了Symfony提供的router_dev.php中的SCRIPT_NAME值。

我像这样运行服务器:app/console server:run

示例1 - GOOD

Directory structure:
web/index.html

Path:
/whatever.something/a-page

SCRIPT_NAME value:
/whatever.something/a-page

示例2 - GOOD

Directory structure (empty):
web/

Path:
/whatever-something/a-page

SCRIPT_NAME value:
/whatever-something/a-page

示例3 - WEIRD!

Directory structure:
web/index.html

Path:
/whatever-something/a-page

SCRIPT_NAME value:
/index.html

这会导致我的应用基本上为每个不包含句点的请求提供index.html。

有人能告诉我到底是怎么回事吗?

0 个答案:

没有答案