Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 多个URL只承载一个需要https_.htaccess_Ssl_Https_Multiple Sites - Fatal编程技术网

.htaccess 多个URL只承载一个需要https

.htaccess 多个URL只承载一个需要https,.htaccess,ssl,https,multiple-sites,.htaccess,Ssl,Https,Multiple Sites,我在一台服务器上有几个站点,但其中一个URL需要是https 例如: 我一直在使用htaccess强制使用https,但它对所有URL都这样做,基本上破坏了所有URL,除了一个我有SSL证书的URL 如何在该站点上强制使用https?您可以在htaccess中使用双重条件: -条件1:仅检查www.example2.com -条件2:仅检查http请求 RewriteCond %{HTTP_HOST} ^www\.example2\.com$ [NC] RewriteCond %{HTTPS}

我在一台服务器上有几个站点,但其中一个URL需要是https

例如:

我一直在使用htaccess强制使用https,但它对所有URL都这样做,基本上破坏了所有URL,除了一个我有SSL证书的URL


如何在该站点上强制使用https?

您可以在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
等效+1以使用
example.com