打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
IIS7的http 做301重定向到https

我们的香港空间部分是windows下的IIS平台,一些用户安装了SSL https证书后,不会控制301跳转,下面直接贴出代码,根据需要把代码放到web.config文件里即可。


http跳转到https

这个代码段是http重定向到https, 注意,要放在<rules>和</rules>之间。

<rule name="HTTP to HTTPS redirect" stopProcessing="true">				<match url="(.*)" />				<conditions>				<add input="{HTTPS}" pattern="off" ignoreCase="true" />				</conditions>				<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" /></rule>

http跳转到https

提醒:里面的网址记得改成你自己的网站,别懒得只会copy!

这个代码段是无3w重定向到有3w域名, 注意,要放在<rules>和</rules>之间。

<rule name="www" stopProcessing="true">                    <match url=".*" />                    <conditions>                        <add input="{HTTP_HOST}" pattern="^ip110\.com$" />                    </conditions>                    <action type="Redirect" url="https://www.ip110.com/{R:0}" /> </rule>

完整的web.config代码

下面代码包含了,无3w网址,跳转到有3w网址; 以及, http全部跳转到https

当然了,知道大家懒,已经将两份整合到一起,将下面全部代码保存成web.config文件,存放到空间的web目录下即可。再次提醒:里面的网址记得改成你自己的网站,别懒得只会copy!

<?xml version="1.0" encoding="UTF-8"?><configuration>    <system.webServer>        <rewrite>            <rules>                <rule name="www" stopProcessing="true">                    <match url=".*" />                    <conditions>                        <add input="{HTTP_HOST}" pattern="^ip110\.com$" />                    </conditions>                    <action type="Redirect" url="https://www.ip110.com/{R:0}" />                </rule>				<rule name="HTTP to HTTPS redirect" stopProcessing="true">				<match url="(.*)" />				<conditions>				<add input="{HTTPS}" pattern="off" ignoreCase="true" />				</conditions>				<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />				</rule>			</rules>        </rewrite>    </system.webServer></configuration>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
详解301永久重定向实现方法
IIS服务器中如何实现http自动跳转到https
ASP.NET 301跳转或者进行301重定向/转向的方法
ecshop的IIS7.5上的伪静态规则web.config
seo网站优化做301重定向的作用
IIS7设置http跳转到https重定向的方法
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服