HTTP到HTTPS重定向 - iis8.5 URL重写不工作
问题描述:
我有一个很难得到下面的重定向规则工作2.0重定向规则...HTTP到HTTPS重定向 - iis8.5 URL重写不工作
<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}'后部参考,这应该是'常见问题'
我一直在争取这一段时间,关于这里发生的任何想法会很好。
一些额外的信息是我主持的角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>
由于这条规则'相对路径重写'的问题。这条规则的条件:重定向所有东西,不是'file'或'directory',URL不是'/'。此规则将您从“http:// mywebsite.com/faq”重定向到“http:// mywebsite.com”,然后从“http:// mywebsite.com”重定向到https:// mywebsite。 com' –