如果网址包含/index.php/,则为404页

时间:2014-10-25 02:23:22

标签: php apache .htaccess mod-rewrite redirect

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

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

如果看起来像" example.com/index.php/blog /"我会尝试404网址。但是让网址" example.com/blog /"通过

Htaccess文件

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

提前致谢!

1 个答案:

答案 0 :(得分: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]