【问题标题】:htaccess redirect from old domain to new domain and https and preserve query stringhtaccess 从旧域重定向到新域和 https 并保留查询字符串
【发布时间】:2016-04-15 02:41:06
【问题描述】:

谁能帮我解决我的问题。

我更改了我的 wordpress 网站的域,但在同一台服务器上。

旧网站:https://www.old.net
新网站:https://www.new.com

现在我想进行以下重定向:

http:/www.old.net                --> https:/www.new.com
https:/www.old.net               --> https:/www.new.com
http:/www.new.com                --> https:/www.new.com
http:/www.old.net/example-site   --> https:/www.new.com/example-site
https:/www.old.net/example-site  --> https:/www.new.com/example-site
http:/old.net                    --> https:/www.new.com
https:/old.net                   --> https:/www.new.com
http:/old.net/example-site       --> https:/www.new.com/example-site
https:/old.net/example-site      --> https:/www.new.com/example-site

等等... (我删除了第二个斜线,所以我可以发布这么多示例 URls...)

我希望很清楚我的问题是什么......

我已经试过了:

RewriteCond %{HTTP_HOST} *!^www*.new\.com [NC]
RewriteRule (.*) https://www.new.com/$1 [L,R=301]

还有这个:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*) https://www.new.com%{REQUEST_URI} [R=301,NC]

但这一切都以 500 错误或无限重定向循环结束

感谢您的帮助!

【问题讨论】:

    标签: wordpress .htaccess redirect mod-rewrite


    【解决方案1】:

    要将旧站点重定向到新站点,您可以使用:

    RewriteEngine on
    
    
    RewriteCond %{HTTP_HOST} ^(www\.)?oldsite\.com$
    RewriteRule ^ https://www.newsite.com%{REQUEST_URI} [NE,L,R]
    

    【讨论】:

      猜你喜欢
      • 2012-06-08
      • 1970-01-01
      • 2017-05-15
      • 1970-01-01
      • 2015-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-16
      相关资源
      最近更新 更多