有人知道我如何在下面的 .htaccess 中重定向此规则?
http://www.domain.com/index.php to http://domain.com
和
http://www.domain.com to http://domain.com
许多坦克
有人知道我如何在下面的 .htaccess 中重定向此规则?
http://www.domain.com/index.php to http://domain.com
和
http://www.domain.com to http://domain.com
许多坦克
因为我猜index.php
是当您转到文档根目录时得到的服务,所以您要明确检查所请求/index.php
的是什么,而不是 URI 的一部分,一旦 URL 文件映射管道完成它的工作,它将是.
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php
RewriteRule ^index\.php$ / [L,R=301]
然后将 www 转为非 www:
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]