【问题标题】:404 page if url contains /index.php/如果 url 包含 /index.php/ 则为 404 页面
【发布时间】:2023-04-08 08:23:01
【问题描述】:

我有一个 htaccess 文件,它将所有流量重定向到我的 index.php 以进行路由。

该应用也可以使用这样的网址“example.com/index.php/blog/”

如果 url 看起来像“example.com/index.php/blog/”,我会尝试 404,但让 url “example.com/blog/”通过

Htaccess 文件

# Send the URI to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

提前谢谢!

【问题讨论】:

    标签: php apache .htaccess mod-rewrite redirect


    【解决方案1】:

    您可以插入一个新规则来为您的新需求发送 404:

    RewriteCond %{THE_REQUEST} /index\.php [NC]
    RewriteRule ^ - [L,R=404]
    
    # Send the URI to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-05
      • 2020-07-07
      • 2016-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-28
      • 1970-01-01
      相关资源
      最近更新 更多