本站由源码空间设计梦想站提供技术支持,微信和QQ:80561642


QQ一健登录

微信扫一扫登录

查看: 38  |  回复: 0
web.config设置http重定向301到https方法
楼主
发表于 10月25日 09:11

特别提示:网站一定要安装SSL证书情况下,并且直接访问HTTPS能生效情况下才设置http转https的301重定向,不然生效了由于HTTPS本身不可访问,这样虽然设置重定向成功了,但网站没有正确安装SSL证书会造成无法打开。

IIS下web.config配置HTTP跳转https 301永久重定向代码:

<?xml version=”1.0″ encoding=”UTF-8″?><configuration><system.webServer><httpErrors><remove statusCode=”404″ subStatusCode=”-1″ /><error statusCode=”404″ prefixLanguageFilePath=”” path=”/404.html” responseMode=”ExecuteURL” /></httpErrors><rewrite><rules><rule name=”Imported Rule 1″><match url=”(.*)” /><conditions logicalGrouping=”MatchAll”><add input=”{HTTP_HOST}” pattern=”^sleep-vip.cn$” ignoreCase=”false” /></conditions><action type=”Redirect” url=”https://www.sleep-vip.cn/{R:1}” redirectType=”Permanent” /></rule><rule name=”redirect to HTTPS” stopProcessing=”true”><match url=”(.*)” /><conditions><add input=”{HTTPS}” pattern=”^OFF$” /></conditions><action type=”Redirect” url=”https://{HTTP_HOST}/{R:1}” /></rule></rules></rewrite><defaultDocument><files><clear /><add value=”index.html” /><add value=”index.php” /><add value=”index.htm” /></files></defaultDocument></system.webServer></configuration>

 

 

反选的链接,改成自己网站的域名。

web.config完整文件下载地址:

 

https_301特别提示:网站一定要安装SSL证书情况下,并且直接访问HTTPS能生效情况下才设置http转https的301重定向,不然生效了由于HTTPS本身不可访问,这样虽然设置重定向成功了,但网站没有正确安装SSL证书会造成无法打开。
IIS下web.config配置HTTP跳转https 301永久重定向代码:
<?xml version=”1.0″ encoding=”UTF-8″?>
<configuration>
<system.webServer>
<httpErrors>
<remove statusCode=”404″ subStatusCode=”-1″ />
<error statusCode=”404″ prefixLanguageFilePath=”” path=”/404.html” responseMode=”ExecuteURL” />
</httpErrors>
<rewrite>
<rules>
<rule name=”Imported Rule 1″>
<match url=”(.*)” />
<conditions logicalGrouping=”MatchAll”>
<add input=”{HTTP_HOST}” pattern=”^sleep-vip.cn$” ignoreCase=”false” />
</conditions>
<action type=”Redirect” url=”https://www.sleep-vip.cn/{R:1}” redirectType=”Permanent” />
</rule>
<rule name=”redirect to HTTPS” stopProcessing=”true”>
<match url=”(.*)” />
<conditions>
<add input=”{HTTPS}” pattern=”^OFF$” />
</conditions>
<action type=”Redirect” url=”https://{HTTP_HOST}/{R:1}” />
</rule>
</rules>
</rewrite>
<defaultDocument>
<files>
<clear />
<add value=”index.html” />
<add value=”index.php” />
<add value=”index.htm” />
</files>
</defaultDocument>
</system.webServer>
</configuration>

 


反选的链接,改成自己网站的域名。
web.config完整文件下载地址:

https_301

  • 更对源码请加微信80561642,网址:ymhost.cn
您需要登录后才可以回帖 登录 | 立即注册
本版版规

欢迎光临【网站源码空间设计梦想站】 【淘宝店】

2000多种ASP PHP HTML NET源码 总有一款适合您!

免备案香港虚拟主机30元/年起 会员注册登陆

用户登录
用户名: 立即注册
密码:
快捷登录 :

Powered by ymhost.cn v1.0 服务说明 已累计运营: 13年255天10时56分钟16秒 本站所有源码仅供学习研究使用,商用请自行确认版权
2003-2026 源码空间设计梦想站,浙ICP备2024111239号-1-2-3 浙公网安备33060302001604-5-6号
手机版 | 空间首页 小黑屋 | 论坛首页 | 联系我| 源码空间 | 淘宝店
GMT+8,2026-11-16 08:55:04 今日总访问 加载中... 次 今日总访客 加载中... 人
扫一扫访问
微信80561642