mod_rewrite全部80个stream量到443例外

我有一个运行在443和80上的虚拟主机。在80虚拟主机上,我有一个这样的规则。

Redirect permanent / https://localhost 

我正在testing/ autos静态页面,我希望这个stream量不使用redirect规则,我希望这个页面从80虚拟主机提供没有SSL。 所以我试图设置一个RewriteCond然后一个RewriteRule的cond。

  RewriteCond %https://localhost !/autos$ RewriteRule !^/var/www/autos - [C] 

这不工作,因为我可能做错了。 有小费吗?

我使用了两个vHost定义 – 一个用于http,一个用于https。 对于plone我使用这个:

  RewriteEngine On RewriteRule ^/webalizer(.*) /webalizer$1 [PT] RewriteRule ^/(.*) http://127.0.0.1:9673/VirtualHostBase/http/www.domain.tld:80/zope/VirtualHostRoot/$1 [L,P] 

但也许在https-vHost中这也足够了:

 Redirect permanent /autos http://www.domain.de/autos 

心连心

你必须有可能性:

1)在你的Port 80 VirtualHost上设置一个忽略子文件夹autos的redirect:

 RewriteEngine On RedirectMatch 301 ^((?!(autos)).)*$ https://your-domain.ain/ 

注意:这不会保留URL中的path。 所以http://your-domain.ain/path/to/sth将被redirect到https://your-domain.ain/ 。

2)IMO更好的解决scheme将是为子文件夹自动创build一个自己的VirtualHost。

 <VirtualHost *:80> ServerName autos.yourdomain.ain DocumentRoot /var/www/autos ServerAdmin [email protected] # Write a seperate log per Virtualhost CustomLog /var/log/apache2/autos.access_log combined ErrorLog /var/log/apache2/autos.error_log # Maybe you want to put some restrictions on the directory <Directory /var/www/autos> Options -Indexes +FollowSymLinks + Includes AllowOverride All # Restrict Access to certain IP's (change IP to a real IP or comment out) Order Deny,Allow Deny from All Allow from 127.0.0.1 IP IP IP Satisfy ALL </Directory> </VirtualHost> 

您可以在Apache手册中find有关Apache VirtualHosts和一些示例的 更多信息 。

编辑:对于单独的VHOST,你需要使用NameVirtualHost。 确保您在Apache conf中具有以下条目:

 NameVirtualHost *:80 Listen 80 NameVirtualHost *:443 Listen 443