
linux系统 apache环境
云服务器 .htaccess 内容
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:From-Https} !^on$ [NC]
#RewriteCond %{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>虚拟主机 .htaccess 内容
<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环境
编辑nginx站点配置文件
server
{
listen 80;
server_name abc.com;
rewrite ^(.*) https://www.abc.com$1 permanent; # abc.com对应修改为您自已的域名
}
#亚数机房CDN部署的SSL添加下面代码
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>非亚数机房复制以下规则,注意替换为自己的域名
<?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>虚拟主机 web.config
<?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系统 IIS6环境
httpd.conf 添加以下规则
RewriteEngine On
RewriteCond %{HTTP:From-Https} !^on$ [NC]
#RewriteCond %{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对应修改为您自已的域名tomcat环境
在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>
注: 1、discuz使用301方式强制将http跳转到https后会导致后台uc通信失败。
2、通过该方式设置跳转后,如无法正常跳转访问,请单独建立站点绑定https域名,仍在原来站点设置跳转规则。

支付宝打赏
微信打赏














