1、證書下載
1.1、首頁(yè)點(diǎn)擊SSL證書

image.png
1.2、點(diǎn)擊購(gòu)買證書

image.png
1.3、申請(qǐng)免費(fèi)證書,立即購(gòu)買

image.png
1.4、成功,進(jìn)入證書平臺(tái)

image.png
1.5、申請(qǐng)?zhí)顚憣?duì)應(yīng)域名

image.png

image.png
1.6、驗(yàn)證提交審核,等待通過(guò)

image.png
1.7、通過(guò)后,下載相應(yīng)證書,我自己使用的是Apache

image.png

image.png
2、證書安裝
1.1、文件解壓縮,并放到對(duì)應(yīng)位置;
我自己放置的目錄是:E:\phpStudy\PHPTutorial\Apache\cert

image.png
1.2、進(jìn)入 E:\phpStudy\PHPTutorial\Apache\conf 目錄創(chuàng)建vhostssl.conf文件。
配置代碼如下:
<VirtualHost *:443>
#備注:你的網(wǎng)站根目錄
DocumentRoot "E:\WWW\abc"
#備注:你的要配置的域名
ServerName www.abc.com
#備注:你的主域名
ServerAlias abc.com
SSLEngine on
SSLProtocol TLSv1 TLSv1.1 TLSv1.2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
#備注:你的證書
SSLCertificateFile "E:\phpStudy\PHPTutorial\Apache\cert\www.abc.com_public.crt"
#備注:你的key
SSLCertificateKeyFile "E:\phpStudy\PHPTutorial\Apache\cert\www.abc.com.key"
#備注:你的中間證書
SSLCertificateChainFile "E:\phpStudy\PHPTutorial\Apache\cert\www.abc.com_chain.crt"
#備注:你的網(wǎng)站根目錄
<Directory "E:\WWW\pxwap">
Options +Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
重啟Apache,重啟成功后https 訪問(wèn)。訪問(wèn)成功,則安裝成功。
3、301重定向http跳轉(zhuǎn)https
3.1、Apache服務(wù)器:
3.1.1、網(wǎng)站根目錄創(chuàng)建.htaccess 文件

image.png
3.1.2、全站跳轉(zhuǎn)https配置
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [R=301,L]
</IfModule>
3.1.3、某個(gè)目錄做https強(qiáng)制跳轉(zhuǎn)
RewriteEngine on
RewriteBase /yourfolder
RewriteCond %{SERVER_PORT} !^443$
#RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
如果只需要對(duì)某個(gè)網(wǎng)頁(yè)進(jìn)行https跳轉(zhuǎn),可以使用redirect 301來(lái)做跳轉(zhuǎn)!redirect 301 /你的網(wǎng)頁(yè) https://你的主機(jī)+網(wǎng)頁(yè)
3.2Nginx服務(wù)器:
在配置80端口的文件里面,寫入以下內(nèi)容即可。
server {
listen 80;
server_name localhost;
rewrite ^(.*)$ https://$host$1 permanent;
location / {
root html;
index index.html index.htm;
}
3.3、Nginx服務(wù)器:
IIS中實(shí)現(xiàn)Http自動(dòng)轉(zhuǎn)換到Https方法介紹 (403跳轉(zhuǎn)對(duì)SEO有一定影響),可以采用302重定向方法;
3.3.1、根據(jù)IIS版本備份以下文件:
IIS6.0 路徑:C:\WINDOWS\Help\iisHelp\common\403-4.htm
IIS7.0以上 路徑:C:\inetpub\custerr\zh-CN\403.htm
3.3.2、把以下內(nèi)容全部拷貝替換(403-4或403)里面所有內(nèi)容,保存即可(修改之前先備份下403文件)
<HTML><HEAD><TITLE>該頁(yè)必須通過(guò)安全通道查看</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=GB2312">
</HEAD><BODY>
<script type="text/javascript">
var url = window.location.href;
if (url.indexOf("https") < 0) {
url = url.replace("http:", "https:");
window.location.replace(url);
}
</script>
</BODY></HTML>
3.1.3、把以下內(nèi)容全部拷貝替換(403-4或403)里面所有內(nèi)容,保存即可
勾選網(wǎng)站要求SSL通道訪問(wèn):IIS6中,站點(diǎn)屬性-》目錄安全性-》編輯中把“要求安全通道(SSL)”勾選。IIS7、8中,SSL設(shè)置勾選“要求SSL”即可。(備注:如果IIS上面有多個(gè)站點(diǎn),恢復(fù)以上操作,然后使用下面的“單頁(yè)面跳轉(zhuǎn)通用代碼”)