【问题标题】:htaccess 301 redirect with wildcard to a single pagehtaccess 301 使用通配符重定向到单个页面
【发布时间】:2013-06-30 13:56:45
【问题描述】:

我们接管了一个网站,该网站在旧网站根目录中包含大约十亿个页面,这些页面在 htm 中完成,需要停用。我想使用通配符从页面到新站点根目录中的 index.php 进行 301 重定向。页面命名结构示例如下:

oldpage_dees.htm
oldPage_dat.htm
oldPage_deeudderting.htm

等等。如前所述,我需要将它们重定向到根目录中的 index.php。通过示例和讨论,我已经尝试过:

RewriteEngine On
RewriteRule ^/oldpage_([\w]*).htm$ /index.php  [R=301,L]

但我收到 404 错误。

有什么建议吗?提前致谢!

【问题讨论】:

    标签: .htaccess redirect


    【解决方案1】:

    由于.htaccess是目录级配置文件,你不需要指定正斜杠,我认为这样就可以了:

       RewriteEngine On
       RewriteRule ^oldpage_([\w]*).htm$ index.php  [R=301,L]
    

    同时,您可以使用以下.htaccess tester 来调试您的重写规则。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-04
      • 2018-10-03
      • 1970-01-01
      • 2016-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-22
      相关资源
      最近更新 更多