【问题标题】:multiple urls hosted only one needs https多个 url 托管只有一个需要 https
【发布时间】:2014-09-27 08:08:04
【问题描述】:

我在一台服务器上有多个网站,但其中一个网址必须是 https。

例如: http://www.example1.com/ https://www.example2.com/

我一直在使用 htaccess 来强制使用 https,但它对所有 url 执行此操作基本上破坏了所有 URL,除了我拥有 SSL 证书的一个 URL。

如何在那个网站上强制使用 https?

【问题讨论】:

  • +1 使用example.com

标签: .htaccess ssl https multiple-sites


【解决方案1】:

您可以在 htaccess 中使用双重条件:
- 条件 1:检查 www.example2.com
- 条件 2:检查http 请求

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

这样,来自www.example2.com 的每个http url 都将转到等效的https

【讨论】:

    猜你喜欢
    • 2011-08-29
    • 1970-01-01
    • 1970-01-01
    • 2017-08-23
    • 2014-07-09
    • 2015-02-13
    • 1970-01-01
    • 1970-01-01
    • 2012-10-08
    相关资源
    最近更新 更多