【问题标题】:How to customize redirecting http to https on IIS8.5如何在 IIS8.5 上自定义重定向 http 到 https
【发布时间】: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 上工作。

标签: iis https iis-8.5


【解决方案1】:

您可以添加附加条件“主机不应匹配 192.168.1.100”。

你的规则应该是这样的:

<rule name="HTTPS force" enabled="true" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions>
        <add input="{HTTPS}" pattern="^OFF$" />
        <add input="{HTTP_HOST}" pattern="^192.168.1.100$" negate="true" /> 
    </conditions> 
    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" /> 
</rule> 

【讨论】:

    猜你喜欢
    • 2018-01-18
    • 2017-11-19
    • 1970-01-01
    • 1970-01-01
    • 2011-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-02
    相关资源
    最近更新 更多