注意,以下教程針對我司虛擬主機或者亞數(shù)的云主機香港IP部署SSL后的301跳轉(zhuǎn)(非亞數(shù)機房需要注意規(guī)則中行替換),把規(guī)則中域名替換成自己的
linux系統(tǒng) apache環(huán)境
云服務(wù)器:【直接在apache上部署的SSL】在對應(yīng)站點根目錄下新建(通過ftp或登錄wdcp管理面板中:站點列表-文管-進入public_html-創(chuàng)建文件)一個文件命名為.htaccess。
- <IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteCond %{HTTP:From-Https} !^on$ [NC]
- #RewriteCond %{HTTPS} !^on$ [NC] # 非亞數(shù)機房用這一行替換上一行規(guī)則
- RewriteCond %{HTTP_HOST} ^(www.)?abc.com$ [NC] # 將abc.com和www.abc.com跳轉(zhuǎn)到https://www.abc.com,防止apache子站繼承上級目錄.htaccess受影響
- RewriteRule ^(.*)$ https://www.abc.com/$1 [R=301,L]
- </IfModule>
復(fù)制代碼
虛擬主機:可以通過ftp或登錄后進入到主機管理面板-文件管理,進入wwwroot,新建一個文件命名為.htaccess文件,保存即可。
編輯.htaccess文件寫入以下規(guī)則:
- <P style="PADDING-BOTTOM: 0px; LINE-HEIGHT: 25px; WIDOWS: 2; TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,255,255); FONT-STYLE: normal; TEXT-INDENT: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; FONT-FAMILY: 'Microsoft Yahei', 'Hiragino Sans GB', 'Helvetica Neue', Helvetica, tahoma, arial, Verdana, sans-serif, 'WenQuanYi Micro Hei', 宋體; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(43,43,43); FONT-SIZE: 14px; FONT-WEIGHT: 400; WORD-SPACING: 0px; PADDING-TOP: 0px; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial"> </P>
復(fù)制代碼
- <IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteCond %{HTTP:From-Https} !^on$ [NC]
- RewriteCond %{HTTP_HOST} ^(www.)?abc.com$ [NC] # 將abc.com和www.abc.com跳轉(zhuǎn)到https://www.abc.com,防止apache子站繼承上級目錄.htaccess受影響
- RewriteRule ^(.*)$ https://www.abc.com/$1 [R=301,L]
- </IfModule>
復(fù)制代碼
Nginx環(huán)境
編輯nginx站點配置文件(登錄wdcp管理面板中:站點列表-文管-虛擬主機站點文件nginx-對應(yīng)站點配置文件),添加以下規(guī)則
- server
- {
- listen 80;
- server_name abc.com;
- rewrite ^(.*) https://www.abc.com$1 permanent; # abc.com對應(yīng)修改為您自已的域名
- }
- 亞數(shù)機房CDN部署的SSL添加下面代碼
- if ( $http_from_https != 'on' ){
- rewrite ^(.*) https://www.abc.com$1 permanent; # abc.com對應(yīng)修改為您自已的域名
- }
復(fù)制代碼
Windows系統(tǒng) IIS7環(huán)境
云服務(wù)器:【直接在IIS上部署的SSL】在對應(yīng)站點根目錄下新建(通過ftp或登錄后直接進入到D:\wwwroot\站點ftp命名目錄\wwwroot創(chuàng)建)一個文件命名為web.config并編輯添加以下規(guī)則:
亞洲數(shù)據(jù)中心機房復(fù)制以下規(guī)則,注意更改為自己的域名
- <?xml version="1.0" encoding="UTF-8"?>
- <configuration>
- <system.webServer>
- <rewrite>
- <rules>
- <rule name="301" stopProcessing="true">
- <match url="^(.*)$" ignoreCase="false" />
- <conditions logicalGrouping="MatchAll">
- <add input="{HTTP_FROM_HTTPS}" pattern="^on$" negate="true" />
- </conditions>
- <action type="Redirect" url="https://www.abc.com/{R:1}" redirectType="Permanent" />
- </rule>
- </rules>
- </rewrite>
- </system.webServer>
- </configuration>
復(fù)制代碼 非亞數(shù)機房復(fù)制以下規(guī)則,注意替換為自己的域名
- <SPAN style="WIDOWS: 2; TEXT-TRANSFORM: none; BACKGROUND-COLOR: rgb(255,255,255); FONT-STYLE: normal; TEXT-INDENT: 0px; DISPLAY: inline !important; FONT-FAMILY: 'Microsoft Yahei', 'Hiragino Sans GB', 'Helvetica Neue', Helvetica, tahoma, arial, Verdana, sans-serif, 'WenQuanYi Micro Hei', 宋體; WHITE-SPACE: normal; ORPHANS: 2; FLOAT: none; LETTER-SPACING: normal; COLOR: rgb(43,43,43); FONT-SIZE: 14px; FONT-WEIGHT: 400; WORD-SPACING: 0px; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial"></SPAN>
復(fù)制代碼
- <?xml version="1.0" encoding="UTF-8"?>
- <configuration>
- <system.webServer>
- <rewrite>
- <rules>
- <rule name="301" stopProcessing="true">
- <match url="^(.*)$" ignoreCase="false" />
- <conditions logicalGrouping="MatchAll">
- <add input="{HTTPS}" pattern="^on$" negate="true" />
- </conditions>
- <action type="Redirect" url="https://www.abc.com/{R:1}" redirectType="Permanent" />
- </rule>
- </rules>
- </rewrite>
- </system.webServer>
- </configuration>
復(fù)制代碼 虛擬主機:可以通過ftp或登錄后進入到主機管理面板-文件管理,進入wwwroot,新建一個文件命名為web.config并編輯添加以下規(guī)則,注意替換為自己的域名。 <?xml version="1.0" encoding="UTF-8"?><configuration> <system.webServer> <rewrite> <rules> <rule name="301" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{HTTP_FROM_HTTPS}" pattern="^on$" negate="true" /> </conditions> <action type="Redirect" url="https://www.abc.com/{R:1}" redirectType="Permanent" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
Windows系統(tǒng) IIS6環(huán)境
參考http://www.west.cn/faq/list.asp?unid=650 配置一個Rewrite,編輯該Rewrite的規(guī)則文件httpd.conf 添加以下規(guī)則。
- RewriteEngine On
- RewriteCond %{HTTP:From-Https} !^on$ [NC]
- #RewriteCond %{HTTPS} !^on$ [NC] # 非亞數(shù)機房用這一行替換上一行規(guī)則
- RewriteRule ^(.*)$ https://www.abc.com/$1 [R=301,L] # www.abc.com對應(yīng)修改為您自已的域名
- RewriteCond %{HTTP_HOST} !^www\.
- RewriteRule ^(.*)$ https://www.abc.com$1 [R=301,L] # www.abc.com對應(yīng)修改為您自已的域名
復(fù)制代碼
tomcat環(huán)境
在web.xml最后一行</web-app>代碼之前添加如下代碼即可
- <security-constraint>
- <!-- Authorization setting for SSL -->
- <web-resource-collection >
- <web-resource-name >SSL</web-resource-name>
- <url-pattern>/*</url-pattern>
- </web-resource-collection>
- <user-data-constraint>
- <transport-guarantee>CONFIDENTIAL</transport-guarantee>
- </user-data-constraint>
- </security-constraint>
復(fù)制代碼
注: 1、discuz使用301方式強制將http跳轉(zhuǎn)到https后會導(dǎo)致后臺uc通信失敗。
2、通過該方式設(shè)置跳轉(zhuǎn)后,如無法正常跳轉(zhuǎn)訪問,請單獨建立站點綁定https域名,仍在原來站點設(shè)置跳轉(zhuǎn)規(guī)則。
請根據(jù)操作系統(tǒng)、站點部署數(shù)量選擇以下相應(yīng)參考文檔,文檔僅供參考,如果對技術(shù)不熟悉,建議提交工單,由我司工程師幫您配置(會有費用產(chǎn)生)。
以上內(nèi)容來源于網(wǎng)絡(luò),僅供參考。
|