我有一个Angular 2 rc-2应用程序,实现了基本路由.路径是/path1默认路径和/path2.主路径/重定向到/path1.当我在本地运行它(lite-server)时一切正常.我设法将此应用程序部署到Azure Web应用程序.该应用程序工作正常,但如果我在我进入时刷新页面/path1或/path2我收到此错误:The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
一种可能的方法是实现url重写.我在项目中添加了一个web.config文件
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<!-- check if its path1 url and navigate to default page -->
<rule name="Path1 Request" enabled="true" stopProcessing="true">
<match url="^path1" />
<action type="Redirect" url="/index.html" logRewrittenUrl="true" />
</rule>
<!-- check if its path2 url and navigate to default page …Run Code Online (Sandbox Code Playgroud)