http 到 https 重定向 - iis8.5 url 重写 2.0 重定向规则不起作用

http to https redirect - iis8.5 url rewrite 2.0 redirect rule not working

我很难让下面的重定向规则起作用...

<rules>
<rule name="Relative Path Rewrite" stopProcessing="false">
  <match url=".*" />
  <conditions logicalGrouping="MatchAll">
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    <add input="{REQUEST_URI}" pattern="^/$" negate="true" />
  </conditions>
  <action type="Rewrite" url="/" />
</rule>
<rule name="Ssl Redirect" stopProcessing="false">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTPS}" pattern="^OFF$" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>

问题如下...

如果我输入 http://mywebsite.com it redirects to https://mywebsite.com 没问题。

但是,如果我输入 http://mywebsite.com/faq it is redirecting to https://mywebsite.com instead of https://mywebsite.com/faq,我不明白为什么?它似乎忽略了来自我的匹配项的“{R:1}”反向引用,它应该是 'faq'

我已经为此苦苦挣扎了一段时间,任何关于这里发生的事情的想法都会很棒。

一些附加信息是我正在托管一个应用此规则的 angular 4.0 网站...

颠倒规则奏效了。

<rewrite>
 <rules>
  <rule name="Ssl Redirect" stopProcessing="false">
   <match url="(.*)" />
   <conditions>
    <add input="{HTTPS}" pattern="^OFF$" />
   </conditions>
   <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
  </rule>
  <rule name="Relative Path Rewrite" stopProcessing="false">
   <match url=".*" />
   <conditions logicalGrouping="MatchAll">
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    <add input="{REQUEST_URI}" pattern="^/$" negate="true" />
   </conditions>
   <action type="Rewrite" url="/" />
  </rule>          
 </rules>
</rewrite>