【问题标题】:htaccess rewrite all pages to same page on another domainhtaccess 将所有页面重写到另一个域上的同一页面
【发布时间】:2012-08-14 00:03:59
【问题描述】:

所以我一直在寻找,但到目前为止找不到我正在寻找的东西。看了这篇文章How can I forward ALL pages to the same exact page on a different domain using .htaccess?但是好像只重定向了我的主页。

目前,我正在使用 WordPress,我需要能够将所有页面转发到新域。例如 domain1.com/about-us 需要去 domain2.com/about-us。但我有大约 50 页需要处理。我想看看是否有 1-5 行代码可用于此工作。

谢谢!

【问题讨论】:

    标签: .htaccess redirect


    【解决方案1】:

    尝试将此(在任何 wordpress 规则之上)放入 domain1.com 文档根目录中的 htaccess 文件中:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} domain1.com [NC]
    RewriteRule ^(.*)$ http://domain2.com/$1 [L,R=301]
    

    如果您的 2 个域是不同的网络服务器,或者不共享一个公共文档根目录,您可以使用 mod_alias,将其添加到 domain1.com 的文档根目录中的 htaccess 文件中:

    Redirect 301 / http://domain2.com/
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-26
      • 1970-01-01
      • 2014-09-23
      • 2013-02-24
      • 1970-01-01
      相关资源
      最近更新 更多