IIS重写模块在第一次加载页面时不会重定向

时间:2019-06-04 09:10:21

标签: iis url-rewriting

我使用IIS 6.2托管网站,并且设置了重写模块以将HTTP请求自动重定向到HTTP。 在隐身模式下使用Brownser,当我请求http://版本时,它不会重定向到HTTPs版本。 然后,当我重新加载页面时,我正确地获得了HTTPs版本。

我已经尝试了使用appendQueryString true和false。

这是我的web.config重写部分:

<rewrite>
  <rules>
    <rule name="HTTPS force" enabled="false" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTPS}" pattern="^OFF$" />
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>

我希望每个请求都将作为HTTP服务。 我不想在浏览器选项卡上看到“不安全”。

1 个答案:

答案 0 :(得分:1)

请检查您的规则。我认为此功能未启用。  使用以下规则:

<rule name="Force SSL" enabled="true" stopProcessing="true"> 
   <match url="(.*)" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{HTTPS}" pattern="off" /> 
      </conditions>
   <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="true" redirectType="Permanent" />
</rule>` 

还要启用附加查询字符串,否则此规则将不会在url中添加查询字符串值。

关于, 贾帕(Jalpa)