繁体   English   中英

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,则可以直接重定向到https://mywebsite.com

但是,如果我输入http://mywebsite.com/faq,它将重定向到https://mywebsite.com而不是https://mywebsite.com/faq ,我不知道为什么? 似乎是在忽略来自我的比赛的“ {R:1}”回溯引用,该引用应为“常见问题解答”

我已经对此进行了一段时间的斗争,任何有关这里发生的事情的想法都将是很棒的。

一些其他信息是,我托管了此规则适用于的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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM