1
我已经在Windows 8笔记本电脑(WAMP服务器)上运行Apache 2.4.4,并且发现了.htaccess mod_rewrite规则的一个非常奇怪的行为。Apache重写空正则表达式(根)
我想将我的网站的根重定向到特定的文件。我的.htaccess看起来是这样的:
RewriteEngine On
RewriteBase/
RewriteRule $^ /static/home.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ router.php?url=$1 [L,QSA]
这只有有一个在根目录没有index.php文件。当我创建index.php文件时,Apache将空路径直接重定向到索引文件,并且不会打扰第一个RewriteRule。
有没有办法让这两个RewriteRules和index.php文件一起工作?换句话说,我的例子有效,但我想将router.php
重命名为index.php
并保持两个RewriteRules正常工作。
谢谢!
没错,这可以做到这一点。不幸的是我不能使用它,因为我可能已经过分简化了我的例子。我需要通过index.php文件(我的网站的路由器)处理其他URL。我要更新我的问题。你知道Apache为什么这么做吗? – koubic 2014-10-20 14:43:44
我会等待您的修改建议您一些可能的解决方法 – anubhava 2014-10-20 14:45:42
好吧现在尝试我更新的代码。 – anubhava 2014-10-20 14:59:15