IBM WebSphere 部署 Angular 5 个应用程序并在刷新时获取 404
IBM WebSphere deploy Angular 5 application and getting 404 on refresh
我使用 Angular(当前版本 5)构建全栈应用程序通常后端是 Windows Server
并且它使用 IIS
,因此我知道部署一个 web.config 包含重写模块代码的文件。
问题是该站点是一个 SPA,它需要始终指向 index.html,无论 URL 说什么...
正如我所说,我习惯了 windows ,但后端是 Java 和 IBM Websphere
有人知道我需要做什么才能使 Angular 应用程序正常工作吗?
例如,WINDOWS 的配置是如下所示的 web.config,但这是带有 Java 应用程序的 Websphere,我假设后端是 Linux/unix
<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="/MyApp/" />
<!--<action type="Rewrite" url="/" />-->
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
您需要将以下内容添加到 web.xml,它打包在您应用的 .war 文件中的 WEB_INF 目录中:
<error-page>
<error-code>404</error-code>
<location>/</location>
</error-page>
它告诉应用服务器在发出 404 错误时在应用程序的上下文根中显示资源。
我使用 Angular(当前版本 5)构建全栈应用程序通常后端是 Windows Server
并且它使用 IIS
,因此我知道部署一个 web.config 包含重写模块代码的文件。
问题是该站点是一个 SPA,它需要始终指向 index.html,无论 URL 说什么...
正如我所说,我习惯了 windows ,但后端是 Java 和 IBM Websphere
有人知道我需要做什么才能使 Angular 应用程序正常工作吗?
例如,WINDOWS 的配置是如下所示的 web.config,但这是带有 Java 应用程序的 Websphere,我假设后端是 Linux/unix
<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="/MyApp/" />
<!--<action type="Rewrite" url="/" />-->
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
您需要将以下内容添加到 web.xml,它打包在您应用的 .war 文件中的 WEB_INF 目录中:
<error-page>
<error-code>404</error-code>
<location>/</location>
</error-page>
它告诉应用服务器在发出 404 错误时在应用程序的上下文根中显示资源。