[英].htaccess redirection fails when slash in index.php/
am having the below code in my .htaccess file, 我的.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]
it successfully redirects when www.domainname.com/index.php
to www.domainname.com
. 成功将
www.domainname.com/index.php
重定向到www.domainname.com
。
But it fails to redirect when URL given like www.domainname.com/index.php/
(a URL with slash after index.php) 但是,当给定的URL如
www.domainname.com/index.php/
(在index.php后带有斜杠的URL)时,它无法重定向
Have it this way by making trailing slash optional in both the rules: 通过在两个规则中都使斜杠为可选来实现此目的:
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]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.