Apache Rewrite: Always use HTTPS (how to add an exception)
On mydomain.com, I currently keep all of my apache conf files in:
/etc/httpd/conf.d/
In there I have a file called alwaysHttps.conf that contains:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
I have a bunch of virtualhosts, and for one domain on the site: myotherdomain.com I would like to turn off the auto redirect. Is it possible to setup an exception to the redirect to https, rather than having to get rid of the global alwaysHttps.conf?
<VirtualHost *:80>
DocumentRoot /home开发者_StackOverflow社区/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>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !myotherdomain\.com
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [QSA]
Fantastic!
In my http.conf I have:
NameVirtualHost *:80
NameVirtualHost *:443
Listen 8033
The reason for the listen on 8033 was because I am using OpenVPN's feature to dual use port 80. Once I changed my
<VirtualHost *:80> to
<VirtualHost *:8033>
everything worked.
The curious thing though is why all of my other virtual domains and *.conf files work even though they have
<VirtualHost *:80>
and not
<VirtualHost *:8033>.
Any idea why that would be the case?
精彩评论