2

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

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

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

我怎样才能在那个网站上强制使用 https?

4

1 回答 1

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]

这样,每个httpurl fromwww.example2.com都会变成https等价的

于 2014-08-04T19:32:46.247 回答