國(guó)內(nèi)高防部署證書后自動(dòng)301跳轉(zhuǎn)https訪問
- 威海網(wǎng)站建設(shè) 威海https
- 1015
注意:
1、規(guī)則里面的域名替換為實(shí)際域名
2、服務(wù)器內(nèi)不需要開啟部署HTTPS
3、寶塔面板不要開啟強(qiáng)制HTTPS
apache環(huán)境:
<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子站繼承上級(jí)目錄.htaccess受影響
RewriteRule ^(.*)$ https://www.abc.com/$1 [R=301,L]
</IfModule>
Nginx環(huán)境:
server
{
listen 80;
server_name abc.com;
}
#亞數(shù)機(jī)房CDN部署的SSL在自身網(wǎng)站server配置節(jié)中添加下面代碼
if ( $http_from_https != 'on' ){
rewrite ^(.*) https://www.abc.com$1 permanent; # abc.com對(duì)應(yīng)修改為您自已的域名
}
Windows系統(tǒng) IIS7及以上版本
<?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>
Windows2003系統(tǒng) IIS6環(huán)境
RewriteEngine On
RewriteCond %{HTTP:From-Https} !^on$ [NC]
RewriteRule ^(.*)$ https://www.abc.com/$1 [R=301,L] # www.abc.com對(duì)應(yīng)修改為您自已的域名
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.abc.com$1 [R=301,L] # www.abc.com對(duì)應(yīng)修改為您自已的域名
來源:西部數(shù)碼