在index.php/中使用斜线时.htaccess重定向失败


.htaccess redirection fails when slash in index.php/

我的.htaccess文件中有以下代码

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}' /index'.php
RewriteRule ^index'.php$ / [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}' /home
RewriteRule ^home$ / [L,R=301]

当CCD_ 1到CCD_。

但当给出类似www.domainname.com/index.php/的URL时,它无法重定向(index.php后面带斜线的URL)

这样做吧,在两个规则中都可以选择尾部斜杠:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}' /+index'.php [NC]
RewriteRule ^index'.php/?$ / [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}' /home [NC]
RewriteRule ^home/?$ / [L,NC,R=301]