【问题标题】:.htaccess direct links routing.htaccess 直接链接路由
【发布时间】:2018-10-23 17:07:25
【问题描述】:

我正在使用首页控制器并使用 .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。我该怎么做?

【问题讨论】:

    标签: php apache .htaccess configuration


    【解决方案1】:

    下面应该通过使用 ^.* 将所有重定向到 index.php 来工作

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-09
      • 2018-01-13
      • 2012-11-09
      • 2021-01-05
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      相关资源
      最近更新 更多