【问题标题】:htaccess with wildcard option to move htm or html extension back to the site带有通配符选项的 htaccess 将 htm 或 html 扩展名移回站点
【发布时间】:2019-11-07 05:41:12
【问题描述】:

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

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

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

上述方法无效并显示 404

【问题讨论】:

    标签: wordpress .htaccess


    【解决方案1】:

    试试这个:

    <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>  
    

    问候汤姆

    【讨论】:

      猜你喜欢
      • 2016-01-06
      • 2016-03-01
      • 2013-09-12
      • 1970-01-01
      • 2015-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-14
      相关资源
      最近更新 更多