咨询热线:4006-75-4006
售前:9:00-23:30 备案:9:00-18:00 技术:7*24h
若一个站点同时可通过http和https访问,但需要实现点击http跳转https的效果,该如何实现?
答案是在Web.config添加以下代码实现http跳转到https:
<system.webServer> <rewrite> <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> </rules> </rewrite> </system.webServer>注意:若Web.config已有内容,则在配置文件web.config中添加<rewrite>到</rewrite>部分即可