【发布时间】:2018-03-18 05:47:06
【问题描述】:
我需要在外部网络(互联网)上将 http 重定向到 https,但在本地网络(例如 192.168.1.100)上可以在 http 上运行。我使用了以下配置:
<system.webServer>
<rewrite>
<rules>
<rule name="HTTPS force" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
【问题讨论】:
-
“本地网络,例如 192.168.1.100”是指您什么时候通过此 IP 访问网站?喜欢:
http://192.168.1.100 -
@VictorLeontyev 没错。当用户在本地调用服务器时,IIS 应该在 http 上工作,当通过域通过 Internet 调用时,IIS 应该在 https 上工作。