【问题标题】:301 Redirecting old site to a new one while keeping same hierarchy301 将旧站点重定向到新站点,同时保持相同的层次结构
【发布时间】:2019-05-10 22:40:25
【问题描述】:

我想 301 将我的旧网站重定向到新网站。我想将所有页面从旧站点重定向到新站点主页,希望所有页面都属于此类别

i.e. olddomain.com/articles/1 should be redirected to newdomain.com/articles/1
     olddomain.com/articles/2 should be redirected to newdomain.com/articles/2
     olddomain.com/articles/3 should be redirected to newdomain.com/articles/3

一般来说,我想做的是:

  1. 将 www 和非 www 版本的旧站点重定向到新站点
  2. 将所有页面从旧站点重定向到新站点主页属于该类别的所有页面/articles

这是我到目前为止所做的,但我不确定如何做第二部分。

RewriteEngine on
RewriteCond %{REQUEST_URI}!^/wp-admin/
RewriteCond {HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]

感谢任何帮助。

【问题讨论】:

    标签: wordpress apache .htaccess


    【解决方案1】:

    你可以用这个:

     RewriteEngine on
    #redirect /category/foobar to newdomain.com/category/foobar
     RewriteCond {HTTP_HOST} ^(www\.)?olddomain.com$ [NC]
     RewriteRule ^category/(.*)$ http://www.newdomain.com/categor/$1  [L,R=301]
    #redirect everything else (except /wp-admin)  to the root of new domain
     RewriteCond %{REQUEST_URI} !^/wp-admin/
     RewriteCond {HTTP_HOST} ^(www\.)?olddomain.com$ [NC]
     RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-03
      • 1970-01-01
      • 2015-06-14
      • 2016-06-07
      • 2017-01-08
      • 2015-04-04
      • 2018-05-01
      • 2017-07-25
      相关资源
      最近更新 更多