【问题标题】:htaccess help needed for https sitehttps站点需要htaccess帮助
【发布时间】:2015-10-17 18:04:03
【问题描述】:

所以我被卡住了

我有一个端口 80 流量的重定向,以重定向到网站的 https 版本。所以所有网站都在https上

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]

所有页面都重定向到 https 上的正确版本。

现在我想将域更改为 dom-ain.com,但我被困在如何重定向到这个新的 https 域,一开始可能不是 https。

我在网络上有指向 domain.com 的非 https 版本和 https 版本的反向链接

如果我现在希望站点重定向到新域并且我计划在结构和内容上保持它的精确副本,那么 htaccess 代码应该是什么。

【问题讨论】:

    标签: .htaccess https


    【解决方案1】:

    你可以使用:

    RewriteEngine on 
    RewriteCond %{HTTP_HOST} domain\.com$ [NC,OR]
    RewriteCond %{HTTPS} off
    RewriteRule ^ https://www.dom-ain.com%{REQUEST_URI} [NE,L,R=301]
    

    在新域为https之前,使用:

    RewriteEngine on 
    RewriteCond %{HTTP_HOST} domain\.com$ [NC,OR]
    RewriteCond %{HTTPS} on
    RewriteRule ^ http://www.dom-ain.com%{REQUEST_URI} [NE,L,R=301]
    

    【讨论】:

    • 我是否正确假设如果我不在新域上使用 https 我只是用 http 切换 https ?此外,是否有人点击旧域的旧 https 链接会使用您提供的代码重定向到新域? https} 关闭有什么作用?
    • 是的,我在回答中添加了这一点。 RewriteCond %{HTTPS} 测试域名是否为https。
    猜你喜欢
    • 1970-01-01
    • 2020-05-29
    • 2011-05-22
    • 1970-01-01
    • 2011-10-14
    • 1970-01-01
    • 2013-03-15
    • 2014-06-11
    • 1970-01-01
    相关资源
    最近更新 更多