.htaccess直接链接路由

时间:2018-10-23 17:07:26

标签: php apache .htaccess configuration

我正在使用首页控制器,并使用.htaccess将所有请求路由到index.php:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -!f
RewriteCond %{REQUEST_FILENAME} -!d
RewriteRule . index.php [L,QSA]
</IfModule>

但这是cfg,不适用于直接链接(如http://example.ru/index.html)并打开此.html文件,但即使在这种情况下,我也需要路由到index.php 。我该怎么办?

1 个答案:

答案 0 :(得分:0)

以下应通过使用^。*将所有内容重定向到index.php来工作。

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /index.php [L,QSA]