301 从 .htm 重定向到 /
301 redirect from .htm to /
我刚刚迁移到 WordPress 网站,我的旧网站的 URL 以 .htm 结尾,例如 https://www.example.com/accessories.htm and I would like to 301 redirect all these URLs to root ie https://www.example.com/accessories/ - 我在 htaccess 中尝试了以下代码,但它不起作用
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^\.htm$ /? [R=301,NE,NC,L]
试试这个规则作为你的最重要的规则:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/(\S+)\.html?\s [NC]
RewriteRule ^ /%1/ [L,NE,R=301]
# remaining rules go here
我刚刚迁移到 WordPress 网站,我的旧网站的 URL 以 .htm 结尾,例如 https://www.example.com/accessories.htm and I would like to 301 redirect all these URLs to root ie https://www.example.com/accessories/ - 我在 htaccess 中尝试了以下代码,但它不起作用
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^\.htm$ /? [R=301,NE,NC,L]
试试这个规则作为你的最重要的规则:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/(\S+)\.html?\s [NC]
RewriteRule ^ /%1/ [L,NE,R=301]
# remaining rules go here