带有通配符选项的htaccess,可将htm或html扩展名移回站点

我正在尝试将所有以.htm或.html结尾的URL重定向回域。我正在处理的网站以前是静态的,现在已移至Wordpress,但是我需要确保它们不会失去来自Google以前索引的链接的客户。

网站从静态HTML迁移到动态(WordPress)

我尝试过但对正则表达式不太了解的代码 重定向301 /*.htm https://domain.co.uk

以上操作无效,并显示404

whs1234567890 回答:带有通配符选项的htaccess,可将htm或html扩展名移回站点

尝试一下:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteBase /
    RewriteRule ^(.*)\.html$ / [L,R=301]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    RewriteRule ^(.*)\.htm$ / [L,R=301]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>  

关于汤姆

本文链接:https://www.f2er.com/3149200.html

大家都在问