通过在 Angular 应用程序的浏览器中手动输入其 URL 导航到特定页面而不是根页面并避免错误 404 (IIS)

问题描述

所以,我的问题如标题所示。我在网上看了一些文章,还是无法理清。

我使用 IIS 并在其上托管 Angular 应用程序。

如果我在 web.config 中使用了 Internet 建议的简单重定向规则 - 我被重定向到“根”页面,这不是我想要的:我想被重定向到请求的页面。需要一些更奇特的重定向规则吗?

如果我使用散列策略 - 重定向似乎可以正常工作,但它是区分大小写的。我希望它不区分大小写。

请建议我可以详细阅读的解决方案或链接(我已经尝试过 Angular.io,但也没有找到合适的方法)。

当前重定向规则:

<configuration>
  <system.webServer>
    <directoryBrowse enabled="true" />
    <rewrite>
      <rules>
        <rule name="AngularJS Routes" stopProcessing="true">
          <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="^/(api)" negate="true" />
          </conditions>
          <action type="Rewrite" url="/CentralTools" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

当我尝试导航到 - 比方说 - https://github.com/Huy-jpg/faq-accordion-card-main - 我被重定向到 https://xxx.yyy.cloudapp.azure.com/CentralTools/licences(根页面)。如果相关,则应用基本网址为“base href="/CentralTools/

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)