https URL重写重写到域根目录,不保留url结构

时间:2014-07-09 11:20:10

标签: ssl iis-7 url-rewriting web-config iis-7.5

我正在尝试将http上的任何网址重写为https等效内容。

我的规则重写为https,但它默认返回域根,并且不保留网址结构。

即。 http://www.domain.com/dir1 - >重写为 - > https://www.domain.com,而不是https://www.domain.com/dir1

<rewrite>
      <rules>
        <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}" redirectType="SeeOther" />
        </rule>
      </rules>
 </rewrite>

1 个答案:

答案 0 :(得分:0)

这似乎可以胜任......

<rewrite>
 <rules>


 <rule name="HTTP to HTTPS redirect" stopProcessing="true">
    <match url="(.*)" />
      <conditions trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="off" />
      </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" />
 </rule> 

 </rules>
</rewrite>