国内高防部署证书后自动301跳转https访问
注意:
1、规则里面的域名替换为实际域名
2、宝塔面板不要开启强制HTTPS
apache环境:
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP:From-Https} !^on$ [NC] RewriteCond %{HTTP_HOST} ^(www.)?abc.com$ [NC] # 将abc.com和www.abc.com跳转到https://www.abc.com,防止apache子站继承上级目录.htaccess受影响 RewriteRule ^(.*)$ https://www.abc.com/$1 [R=301,L] </IfModule>
Nginx环境:
server { listen 80; server_name abc.com; } #亚数机房CDN部署的SSL在自身网站server配置节中添加下面代码 if ( $http_from_https != 'on' ){ rewrite ^(.*) https://www.abc.com$1 permanent; # abc.com对应修改为您自已的域名 }
Windows系统 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系统 IIS6环境
RewriteEngine On RewriteCond %{HTTP:From-Https} !^on$ [NC] RewriteRule ^(.*)$ https://www.abc.com/$1 [R=301,L] # www.abc.com对应修改为您自已的域名 RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ https://www.abc.com$1 [R=301,L] # www.abc.com对应修改为您自已的域名
版权声明:如无特殊标注,文章均为本站原创,转载时请以链接形式注明文章出处。
评论