gpt4 book ai didi

angular - 我们真的需要 URL 重写模块来在 IIS 上托管 Angular 应用程序吗?

转载 作者:行者123 更新时间:2023-12-02 16:54:53 25 4
gpt4 key购买 nike

对于我们来说,angular 应用程序在 IIS 上没有安装 URL 重写模块的情况下工作。我们是否需要 URL 重写模块来在 IIS 上托管 Angular 应用程序?如果我们不安装它会有什么不同?

它适用于下面的 web.config..我只是评论了重写部分并添加了
默认文件

<?xml version="1.0" encoding="utf-8"?>
<configuration>

<system.webServer>
<!-- <rewrite>
<rules>
<rule name="Angular Routes" 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="/SCOAP/index.html" />
</rule>
</rules>
</rewrite> -->
<defaultDocument enabled="true">
<files>
<add value="index.html" />
</files>
</defaultDocument>
</system.webServer>

</configuration>

最佳答案

Angular 主要用于编写 SPA。因此,您可能会有“/home”、“/products”和其他 url,它们应该运行相同的 Angular 应用程序,但您的应用程序将呈现不同的内容。因此,当用户导航到“yoursite.com/home”时,它应该会看到 Angular 应用主页。如果不进行重写,您只会看到 404(因为源代码中没有/home.html)

关于angular - 我们真的需要 URL 重写模块来在 IIS 上托管 Angular 应用程序吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56855845/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com