注意,以下教程針對我司(秀站云)虛擬主機或者亞數(shù)的云主機香港IP部署SSL后的301跳轉(zhuǎn)(非亞數(shù)機房需要注意規(guī)則中行替換),把規(guī)則中域名替換成自己的。
linuxt系統(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 ^(.*)$ http://mengdiqiu.com.cn/$1 [R=301,L]
</IfModule>
|
虛擬主機:可以通過ftp或登錄后進入到主機管理面板-文件管理,進入wwwroot,新建一個文件命名為.htaccess文件,保存即可。
編輯.htaccess文件寫入以下規(guī)則:
<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 ^(.*)$ http://mengdiqiu.com.cn/$1 [R=301,L]
</IfModule>
|
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 ^(.*) http://mengdiqiu.com.cn$1 permanent; # abc.com對應(yīng)修改為您自已的域名
}
|
Windows系統(tǒng) II7環(huán)境
云服務(wù)器:【直接在IIS上部署的SSL】在對應(yīng)站點根目錄下新建(通過ftp或登錄后直接進入到D:\wwwroot\站點ftp命名目錄\wwwroot創(chuàng)建)一個文件命名為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" />
<!-- <add input="{HTTPS}" pattern="^on$" negate="true" /> --> # 非亞數(shù)機房用這一行替換上一行規(guī)則
</conditions>
<action type="Redirect" url="http://mengdiqiu.com.cn/{R:1}" redirectType="Permanent" /> # www.abc.com對應(yīng)修改為您自已的域名
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
|
<?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="http://mengdiqiu.com.cn/{R:1}" redirectType="Permanent" /> # www.abc.com對應(yīng)修改為您自已的域名
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
|