【发布时间】:2013-11-06 16:47:56
【问题描述】:
我正在寻找执行以下操作的.htaccess:
对于访问
mydomain.com的用户,服务器应该从根目录返回index.html文件。对于访问
mydomain.com/something/、mydomain.com/anything/123/、mydomain.com/some%20encoded%20text等的用户,服务器应从根目录返回index.php文件,并将www.mydomain.com/后面的文本作为PHP@987654329传递@变量。
我试过 WordPress .htaccess:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
但这会将所有内容重定向到 index.php 文件。
【问题讨论】:
-
为什么不直接将所有流量导向 index.php,如果没有额外的 URI 传递,只提供 index.html 内容?网站中除一个之外的所有页面都有一个前端控制器似乎很奇怪。
-
@MikeBrant 我希望大多数流量直接来到 mydomain.com,所以我认为提供静态 html 文件比提供 php 更好。
-
我添加了最初尝试的解决方案。
标签: php regex apache .htaccess mod-rewrite