简体   繁体   English

Web.config 重写规则 http 到 https 和 ZD18B8624A0F5F721DA7B8236 路由组合

[英]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.

相关问题 使用web.config的Azure和Angular应用不会根据URL路由进行版本控制(两个实时版本) - Azure and Angular app using web.config are not versioning depending on URL route (two live versions) 有没有办法在 Angular 中动态选择 web.config? - Is there a way to dynamically choose web.config in Angular? 无效的web.config导致HTTP 502.5错误 - Invalid web.config causes HTTP 502.5 error Web.Config 文件无法在 Angular 应用程序中加载 - Web.Config File is not able to load in Angular Application 即使配置了web.config,Angular 7应用程序刷新也无法在IIS上运行 - Angular 7 app refresh not working on IIS even with web.config configured Angular 13 app + api rest. Web.config 配置 - Angular 13 app + api rest. Web.config configuration 所有组件和服务如何访问MVC + Angular5项目的web.config中定义的Web.Config密钥 - How all components & services can access Web.Config Keys defined in web.config of MVC+Angular5 Project Angular 7 IIS 重写规则 - Angular 7 IIS rewrite rule 为什么托管在 Azure web.config 文件上的 Angular Web 应用程序不起作用? - Why is my Angular Web app hosted on Azure web.config file not working? 使用 web.config 在 IIS 服务器上部署 Angular 9 通用 9? 如何在 IIS 服务器上部署 angular 9 服务器端渲染 - Angular 9 universal 9 deployment on IIS server with web.config? How to deploy angular 9 Server side rendering on IIS server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM