是否可以使用相同的Apache服务于同一主机上的网站,其中一些位于https中,而另一些则位于简单的http中?
如果有可能,谁能给我一个提示使其可行?
提前致谢!!
在Apache中使用config:
您可以将多个块用于不同的网站名称,以便它们侦听HTTP或HTTPS(需要端口)
Listen 443 http
Listen 80
NameVirtualHost *:80
NameVirtualHost *:443
ServerName *:80
<VirtualHost *:443>
[some non-ssl stuff(directory, docroot)]
ServerName account.example.com
SSLEngine on
SSLCertificateFile /Users/myusername/certs/server.crt
SSLCertificateKeyFile /Users/myusername/certs/server.key
</VirtualHost>
<VirtualHost *:80>
SSLEngine off
[other stuff like docroot]
</VirtualHost>
为了使单个网站在两个端口上均能正常工作,请在http vhost的.htaccess文件中添加重写规则以从http重定向到https:
#Redirrect from http to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
完毕。您现在将可以同时使用HTTP和HTTPS。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句