【问题标题】:How to redirect all wordpress posts and pages to a new domain.?如何将所有 wordpress 帖子和页面重定向到新域。?
【发布时间】:2013-05-16 03:20:33
【问题描述】:

我需要一个 301 重定向

www.old-domain.com/simple-post/ 去 www.new-domain.com(不是 new-domain.com/simple-post)

我尝试使用一些 .htaccess 规则但什么也没做,

mod-rewrite 已启用

谢谢

【问题讨论】:

    标签: wordpress redirect


    【解决方案1】:

    如果您要将您的 WordPress 网站从一个域转移到另一个域,这就是要走的路:

    http://codex.wordpress.org/Moving_WordPress

    几乎所有这些行都可以解决问题:

    //FIXME: do comment/remove these hack lines. (once the database is updated)
    update_option('siteurl', 'http://your.domain.name/the/path' );
    update_option('home', 'http://your.domain.name/the/path' );
    

    当然,您还需要更改帖子和/或模板文件中的每个静态链接。

    这是一个可以帮助替换内容中的链接的链接:

    http://lorelle.wordpress.com/2005/12/01/search-and-replace-in-wordpress-mysql-database/

    【讨论】:

      【解决方案2】:

      将此代码放在 header.php 上 传入“get_the_ID(1)”post(simple-post)id。 设置重定向网址。

      <?php if (get_the_ID(1)) { ?>
         <script type="text/javascript">
               window.location = "http://www.google.com"; 
         </script>
      <?php } ?>
      

      【讨论】:

      • 谢谢。它成功了。如果我想将使用 costum 帖子类型的 wordress 域重定向到不使用 costum 帖子类型的新域怎么办。我的意思是 domain1.com/article/post-name 到 domain2.com/post-name?
      猜你喜欢
      • 2012-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-28
      • 2011-09-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多