Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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 如何把;及;及;或;条件在二级吗?_Apache_.htaccess_Http_Url_Mod Rewrite - Fatal编程技术网

Apache 如何把;及;及;或;条件在二级吗?

Apache 如何把;及;及;或;条件在二级吗?,apache,.htaccess,http,url,mod-rewrite,Apache,.htaccess,Http,Url,Mod Rewrite,这是我当前的VirtualHost节点: <VirtualHost *:80> ServerName abc.com ServerAlias abc.com www.abc.com RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule ^/?(.*) https://%{SERVER_NAME}/ [NC,R,L] </VirtualHost> 服务器名abc.com ServerAlias

这是我当前的
VirtualHost
节点:

<VirtualHost *:80>
  ServerName abc.com
  ServerAlias abc.com www.abc.com
  RewriteEngine on
  RewriteCond %{HTTPS} !=on
  RewriteRule ^/?(.*) https://%{SERVER_NAME}/ [NC,R,L]
</VirtualHost>

服务器名abc.com
ServerAlias abc.com www.abc.com
重新启动发动机
重写cond%{HTTPS}=在…上
重写规则^/?(*)https://%{SERVER_NAME}/[NC,R,L]
它表示,每个到达此服务器的请求:80将重定向到
HTTPS
。现在我想将
条件添加到
VirtualHost
节点。因此,它将按如下方式工作:

  • 如果请求:80来自xyz.com,则不会重定向到
    HTTPS
  • 如果请求:80来自abc.com,则它将重定向到
    HTTPS
我该怎么做

你可以说:

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

RewriteCond %{HTTP_HOST} ^(www\.)?xyz\.com$ [NC]
RewriteCond %{HTTPS} on
RewriteRule ^/?(.*)$ http://%{HTTP_HOST}/$1 [NE,R,L]

我以为你想强制avc.com使用https