所以我在Apache中配置了fallbackresource,将请求发送到webroot中的index.php,除非我在webroot目录中调用一个不存在的php文件,否则它似乎有效.例如,如果我尝试获取不存在的"/a.php",则会出现404错误.但是,如果我调用"/nodir/a.php",它会按预期将其发送到index.php文件.
我搜索了谷歌并阅读了该功能的Apache文档,但还没有找到为什么会发生这种情况.
我的安装服务器版本:Apache/2.2.20(Ubuntu)在目录部分下使用带默认配置的默认网站"FallbackResource /index.php"
有任何想法吗?
我可以使用mod_rewrite在.htaccess中使用以下基本行来正常工作,但显然更喜欢FallbackResource:
(.htaccess in webroot)
RewriteEngine On
RewriteCond /var/www/%{REQUEST_FILENAME} !-f
RewriteCond /var/www/%{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /a.php HTTP/1.1
HOST: localhost
Connection: close
HTTP/1.1 200 OK
Date: Sat, 31 Dec 2011 02:37:48 GMT
Server: Apache/2.2.20 (Ubuntu)
X-Powered-By: PHP/5.3.6-13ubuntu3.3
Vary: Accept-Encoding
Content-Length: 43
Connection: close
Content-Type: text/html
/a.php
localhost
Connection closed by foreign host.
Run Code Online (Sandbox Code Playgroud) apache2 ×1