.htaccess将网址重定向到另一个网址(保留网址段)

时间:2012-12-17 13:29:19

标签: .htaccess url redirect

需要重定向http:// www.old-url.com/any/other/url/segmenthttps:/ /www.new-url.com/any/other/url/segment

目前我正在做这样的事情:

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

结果:

http:// www.old-url.com/any/other/url/segment to
https:// www.new-url.com/

由于 -Robbie

1 个答案:

答案 0 :(得分:0)

使用以下htaccess规则将http重定向到https:

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

来源:htaccess redirect