Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/301.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
Apache 一台主机上的多个域https和http_Apache_.htaccess_Https - Fatal编程技术网

Apache 一台主机上的多个域https和http

Apache 一台主机上的多个域https和http,apache,.htaccess,https,Apache,.htaccess,Https,我在一台主机上有多个域,我的.htaccess如下所示 RewriteEngine On RewriteCond %{HTTP_HOST} web1.com$ [NC] RewriteCond %{REQUEST_URI} !^/web_1/public/.*$ RewriteRule ^(.*)$ /web_1/public/$1 [L] RewriteCond %{HTTP_HOST} web2.com$ [NC] RewriteCond %{REQUEST_URI} !^/web_2/

我在一台主机上有多个域,我的.htaccess如下所示

RewriteEngine On
RewriteCond %{HTTP_HOST} web1.com$ [NC]
RewriteCond %{REQUEST_URI} !^/web_1/public/.*$
RewriteRule ^(.*)$ /web_1/public/$1 [L]

RewriteCond %{HTTP_HOST}  web2.com$ [NC]
RewriteCond %{REQUEST_URI} !^/web_2/public/.*$
RewriteRule ^(.*)$  /web_2/public/$1 [L]
到目前为止,它仍然有效。现在,我只希望web1.com而不是web2.com重定向到https。如何更改设置?(我也非常感谢您提供有关如何更改我的“实现”的提示,到目前为止,我还不熟悉.htaccess,并愿意了解更多有关它的信息)

尝试以下方法:

RewriteCond %{HTTPS} !=on 
RewriteCond %{HTTP_HOST}  web2.com$ [NC]
RewriteRule ^(.*)$  https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
因此,您的规则如下所示:

RewriteEngine On
RewriteCond %{HTTP_HOST} web1.com$ [NC]
RewriteCond %{REQUEST_URI} !^/web_1/public/.*$
RewriteRule ^(.*)$ /web_1/public/$1 [L]

RewriteCond %{HTTPS} !=on 
RewriteCond %{HTTP_HOST}  web2.com$ [NC]
RewriteRule ^(.*)$  https://%{HTTP_HOST}/$1 [L,R=301]

RewriteCond %{HTTP_HOST}  web2.com$ [NC]
RewriteCond %{REQUEST_URI} !^/web_2/public/.*$
RewriteRule ^(.*)$  /web_2/public/$1 [L]