如何重定向 *.htm *,htm *,html 到 *.html in .htaccess
How to redirect *.htm *,htm *,html to *.html in .htaccess
我需要将 *.htm *,htm *,html
重定向到 *.html
,但是当页面为 *.html
时保持不变 URL *.html
.
我有这个规则,但是有问题 -> 重定向循环。我应该改变什么?
RewriteEngine On
RewriteRule ^(.*)(\.|,)htm(l?)$ .html [R=301]
正如 CBroe 正确评论的那样,问题出在您的模式也匹配 .html
因此会导致重定向循环。
您可以使用以下方法修复它:
RewriteRule ^(.+)(?:\.htm|,html?)$ .html [R=301,L,NC,NE]
PS:假设之前使用了 RewriteBase
指令。
我需要将 *.htm *,htm *,html
重定向到 *.html
,但是当页面为 *.html
时保持不变 URL *.html
.
我有这个规则,但是有问题 -> 重定向循环。我应该改变什么?
RewriteEngine On
RewriteRule ^(.*)(\.|,)htm(l?)$ .html [R=301]
正如 CBroe 正确评论的那样,问题出在您的模式也匹配 .html
因此会导致重定向循环。
您可以使用以下方法修复它:
RewriteRule ^(.+)(?:\.htm|,html?)$ .html [R=301,L,NC,NE]
PS:假设之前使用了 RewriteBase
指令。