[英]Web.config rewrite rule http to https and angular route combination
I have the following rewrite rules at IIS for an angular application:对于 angular 应用程序,我在 IIS 有以下重写规则:
<rewrite>
<rules>
<rule name="Angular Routes1" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.html" />
</rule>
<rule name="HTTPS Redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://www.example.com{REQUEST_URI}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
When someone browses http://www.example.com , its being redirected to https://www.example.com , but when I use a route that setup the website, for example: When someone browses http://www.example.com , its being redirected to https://www.example.com , but when I use a route that setup the website, for example:
http://www.example.com/layout/dark it is not redirecting to https://www.example.com/layout/dark http://www.example.com/layout/dark它没有重定向到https://www.example.com/layout/dark
I am wondering if Im making a mistake when adding two rules, and it should be all added into one rule.我想知道我在添加两条规则时是否犯了错误,应该全部添加到一条规则中。
Thanks.谢谢。
You can put the http to https rule first and try again.可以先把 http 到 https 规则再试。 If it still does not work, you can use failed request tracking to view detailed error reasons.
如果仍然不起作用,您可以使用失败的请求跟踪来查看详细的错误原因。
Using Failed Request Tracing to Trace Rewrite Rules . 使用失败的请求跟踪来跟踪重写规则。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.