htaccess force /使用index.php尽管有其他规则

时间:2015-01-05 01:37:25

标签: apache .htaccess mod-rewrite

htaccess显式将/重定向到index.php,尽管其他规则将/something映射到another.php?q=something

冲突规则为RewriteRule ^([^/]+)$ another.php?q=$1 [QSA]。我在冲突规则上面尝试了RewriteRule ^([^/]+)$ index.php [QSA]但是将映射正确地映射到another.php

关于如何编写正确的htaccess规则的任何想法?

1 个答案:

答案 0 :(得分:0)

您可以使用DirectoryIndex来处理/

DirectoryIndex index.php

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ another.php?q=$1 [QSA,L]