【问题标题】:Angular website problem with Azure on page reloadAzure 在页面重新加载时出现 Angular 网站问题
【发布时间】:2019-05-01 13:45:36
【问题描述】:

问题:每当我重新加载除主页面之外的任何页面时,我都会收到 404 Not Found 错误。它只发生在 Azure 上(本地主机工作正常)。 我正在使用 Angular 5。 这是浏览器在页面重新加载时向我显示的内容: “您要查找的资源已被删除、更改名称或暂时不可用。”
网址:http://learnwithmentor.azurewebsites.net/
Web.config:https://github.com/ss-ita/learnwithmentor-server/blob/master/LearnWithMentor/Web.config

【问题讨论】:

  • 你能发布你的web.config的内容吗

标签: angular azure


【解决方案1】:

您可能正在使用 Angular 路由,对吧?您需要添加一些 URL 重写,因为 IIS 当前正在检查您的 URL 指向的文件或目录是否存在。既然他们不这样做,它会给你一个错误消息。

这进入你的web.configsystem.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="/" />
    </rule>
  </rules>
</rewrite>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-08-16
    • 1970-01-01
    • 2019-05-17
    • 2023-03-07
    • 2018-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多