Listen 443
SSLPassPhraseDialog builtin
SSLSessionCache “shmcb:/Apache24/logs/ssl_scache(512000)”
SSLSessionCacheTimeout 300
# 开启ssl引擎
SSLEngine On
# 服务器证书公钥
SSLCertificateFile “conf/ssl/freessl/full_chain.pem”
# 服务器证书私钥
SSLCertificateKeyFile “conf/ssl/freessl/private.key”
# 证书链文件
SSLCertificateChainFile “conf/ssl/freessl/full_chain.pem”
# 指定站点根目录
DocumentRoot “C:\www\maku\public”
# 指定站点使用的域名和别名
ServerName www.upmart.cn:443
ServerAlias upmart.cn:443
ErrorLog “logs/error.log”
1,Apache服务器:
如果需要整站跳转,则在网站的配置文件的
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.)?$ https://%{SERVER_NAME}/$1 [L,R]
或者
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.) https://%{SERVER_NAME}/$1 [R,L]
2,如果对某个目录做https强制跳转,则复制以下代码:
RewriteEngine on
RewriteBase /yourfolder
RewriteCond %{SERVER_PORT} !^443$
#RewriteRule ^(.)?$ https://%{SERVER_NAME}/$1 [L,R]
RewriteRule ^.$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
3,Nginx服务器:
在配置80端口的文件里面,写入以下内容即可:
server {
listen 80;
server_name localhost;
rewrite ^(.)$ https://$host$1 permanent;
location / {
root html;
index index.html index.htm;
}
4,TOMCAT服务器:
1、在conf目录下的server.xml文件中找到以下配置,修改redirectPort参数值为”443″,默认是“8443”:
在conf目录下的web.xml文件内容
………
5,单独页面PHP页面跳转:
添加在网站php页面内:
if ($_SERVER[“HTTPS”] <> “on”)
{
$xredir=”https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI“];
header(“Location: “.$xredir);
}
6,LAMP或者LNMP集成环境跳转:
首先在网站根目录下创建.htaccess文件,如果目录下已经有.htaccess文件,则用vi或者其他编辑器打开,在最下面添加写入如下语句即可:
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
