Apache Rewrite:始终使用 HTTPS(如何添加例外)
在 mydomain.com 上,我目前将所有 apache conf 文件保存在:
/etc/httpd/conf.d/
在那里我有一个名为 alwaysHttps.conf 的文件,其中包含:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
我有一堆虚拟主机,对于网站上的一个域: 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>
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/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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
极好的!
在我的 http.conf 中,我有:
侦听 8033 的原因是因为我使用 OpenVPN 的功能来双重使用端口 80。一旦我更改了一切,
一切就正常了。
但奇怪的是,为什么我的所有其他虚拟域和 *.conf 文件都可以工作,即使它们有而不
知道
为什么会出现这种情况?
Fantastic!
In my http.conf I have:
The reason for the listen on 8033 was because I am using OpenVPN's feature to dual use port 80. Once I changed my
everything worked.
The curious thing though is why all of my other virtual domains and *.conf files work even though they have
and not
Any idea why that would be the case?