【问题标题】:Redirect 301 for entire site with exceptions为整个站点重定向 301,但有例外
【发布时间】:2018-01-30 06:02:49
【问题描述】:

我一直无法找到可靠的解决方案。

我想将所有域重定向到一个新域,即

www.olddomain.com/post236 重定向到 www.newdomain/posts236

但我有几个例外

即www.olddomain.com/about-us/ 重定向到 www.newdomain.com/about/

我该怎么做?

【问题讨论】:

    标签: .htaccess redirect


    【解决方案1】:

    您可以在 htaccess 中使用以下重定向:

    RedirectMatch 301 ^/about-us/?$ http://newdomain.com/about
    RedirectMatch 301 ^/(.*)$ http://newdomain.com/$1
    

    注意:第二行重定向来自旧域的所有请求。如果您在重定向上有更多例外,只需将它们放在上面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-24
      • 2014-12-16
      • 2015-08-22
      • 1970-01-01
      • 2017-10-20
      • 2011-02-07
      相关资源
      最近更新 更多