Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.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
Regex Apache.htaccess重写规则的两个条件?_Regex_Apache_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

Regex Apache.htaccess重写规则的两个条件?

Regex Apache.htaccess重写规则的两个条件?,regex,apache,.htaccess,mod-rewrite,url-rewriting,Regex,Apache,.htaccess,Mod Rewrite,Url Rewriting,我在弄清楚自己做错了什么方面有点小问题。我有一个网站,我只有两个不同URL的https-www.example.de和example.de。但是,我也指定了子域-x.example.de和y.example.de(如果相关的话,它们是从一个不同的域名中使用的) 所以我尝试了以下代码: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} !=on [NC] # RewriteCond %{HTTP_HOST}

我在弄清楚自己做错了什么方面有点小问题。我有一个网站,我只有两个不同URL的https-www.example.de和example.de。但是,我也指定了子域-x.example.de和y.example.de(如果相关的话,它们是从一个不同的域名中使用的)

所以我尝试了以下代码:

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{HTTPS} !=on [NC]
# RewriteCond %{HTTP_HOST} =^(example.de|www.example.de)  [NC]    
RewriteCond %{HTTP_HOST} !^(x|y)\.example\.de$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST} [R=301,L]

</IfModule>

重新启动发动机
重写cond%{HTTPS}=关于[NC]
#RewriteCond%{HTTP_HOST}=^(example.de| www.example.de)[NC]
重写cond%{HTTP_HOST}^(x|y)\.示例\.de$[NC]
重写规则^(.*)$https://%{HTTP_HOST}[R=301,L]

我尝试过的每一件事都失败了,尤其是上面两件事;例如,在上面的代码中,它将http更改为https,即使它是x或y子域。有人能帮忙吗?谢谢大家!

代码中还有一行没有显示-很抱歉,我离开了几天。。。是的,它们都使用相同的htaccess文件。感谢您帮助我正确显示代码:-)我想我成功了:-)第二个条件是这个RewriteCond%{HTTP_HOST}^(example.de | www.example.de)[NC]这似乎工作得很好!谢谢大家的帮助!