我有一个页面:
http://domain.com/index.php
但奇怪的是,以下 urls
也可以正常工作并呈现相同的页面:
http://domain.com/index.php/abcd
http://domain.com/index.php/gefe
等等..
很明显,这似乎是一个搞砸了的 regex
配置。但奇怪的是,即使我删除了 .htaccess
文件,这些 url 仍然有效。
现在,我只能责怪我的 apache
配置,但一切似乎都符合预期。
我的 apache 配置:
<VirtualHost *:80>
# Server name
ServerName domain.com
# Document root
DocumentRoot /path/to/source
<Directory />
Options FollowSymLinks
</Directory>
<Directory /path/to/source>
AllowOverride All
Options Indexes FollowSymLinks MultiViews
Order allow,deny
allow from all
</Directory>
LogLevel error
# Logs
ErrorLog ${APACHE_LOG_DIR}/domain_error.log
CustomLog ${APACHE_LOG_DIR}/domain_access.log combined
RewriteMap lc int:tolower
</VirtualHost>
谁能指出错误?
最佳答案
它叫做 PATH_INFO。 Apache 将从左到右扫描 URL。只要找到匹配的目录,它就会继续执行文档根目录,直到用完目录或找到匹配的脚本。之后,任何额外的“路径”信息都会变成 PATH_INFO,例如
你有一个网站,在/a/b/c 的真实存在的目录结构中有一个名为“foo.php”的脚本,所以
http://example.com/a/b/c/foo.php
是一个有效的 url。
在那种情况下,
http://example.com/a/b/c/foo.php/bar/baz/bip/bop/boop
^^^^^^^^^^^^^^^^^^^^^-- path info
向上阅读:http://httpd.apache.org/docs/current/mod/core.html#acceptpathinfo
关于php - 当没有这样的文件时,什么 apache 配置导致 domain.com/index.php/abcdefg 工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16924344/