2010-07-14 54 views
2

在mydomain.com,我现在把所有的我的Apache conf文件中:阿帕奇重写:始终使用HTTPS(如何添加一个例外)

/etc/httpd/conf.d/ 

在那里我有一个名为alwaysHttps.conf文件包含:

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 

我有一堆virtualhosts,并在网站上一个域:myotherdomain.com我想关闭自动重定向。是否有可能设置重定向到https的例外,而不是必须摆脱全局alwaysHttps.conf?

<VirtualHost *:80> 
    DocumentRoot /home/webadmin/myotherdomain.com/html 
    ServerName myotherdomain.com 
    CustomLog "/home/webadmin/myotherdomain.com/access_log" "combined" 
    ErrorLog "/home/webadmin/myotherdomain.com/error_log" 
    <Directory /home/webadmin/myotherdomain.com/html> 
     Options Includes FollowSymLinks 
     AllowOverride All 
    </Directory> 
</VirtualHost> 

回答

3
RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteCond %{HTTP_HOST} !myotherdomain\.com 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [QSA] 
+0

行 - 完美!谢谢... 解决了重定向问题,但现在我得到404s。我的域名conf文件是: 如果我放弃修复并将80:443页面加载。但现在的情况是,他们没有。任何快速的想法? – NinjaCat 2010-07-14 16:19:27

+0

你在你的配置中有没有'NameVirtualHost *:80'和'Listen 80'? – Wrikken 2010-07-14 16:29:38

0

太棒了!

在我的http.conf我:

NameVirtualHost *:80 
NameVirtualHost *:443 

Listen 8033 

的原因监听8033是因为我使用OpenVPN的功能,双重用途端口80。有一次,我改变了我的

一切正常。

好奇的事情,虽然是,即使他们有

<VirtualHost *:80> 

,为什么我的所有其他虚拟域和* conf文件工作不

<VirtualHost *:8033>. 

任何想法,为什么会是这样?

+0

我试图离开这作为评论,但该按钮不可见... – NinjaCat 2010-07-15 18:03:46

+0

使用原始帖子上的编辑按钮,并创建一个新的部分 – Andreas 2014-05-01 21:17:24