高手的存在,就是让服务10亿人的时候,你感觉只是为你一个人服务......

apache http跳转https

目录
  1. 1. 全部http请求跳转https
  2. 2. 单url跳转

apache中开启转发配置,将http跳转到https

#开启apache的rewrite模块
Alt text

全部http请求跳转https

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Listen 443
NameVirtualHost *:443
<VirtualHost *:443>
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile "/opt/xyz/apache2.2.9_resin3.0.25/etc/apache2/server.crt"
SSLCertificateKeyFile "/opt/xyz/apache2.2.9_resin3.0.25/etc/apache2/server.key"
SSLCertificateChainFile "/opt/xyz/apache2.2.9_resin3.0.25/etc/apache2//intermediate.crt"
</VirtualHost>
<VirtualHost *:80>
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/?(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
</VirtualHost>

单url跳转

比如http://sales.vemic.com/logon.do 跳转到https://sales.vemic.com/logon.do

1
2
3
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/logon.do$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]