【发布时间】:2019-02-21 09:41:13
【问题描述】:
我正在尝试弄清楚如何设置 Apache Tomcat 服务器以在页面刷新时为 Angular 应用程序提供服务。
只有当我点击时路由才会起作用,但如果手动输入路径或如果我刷新页面,那么它会给我 404 错误。
HTTP 状态 404 - 未找到
1) 使用以下方法构建 Angular 应用程序:
ng build --prod --base-href ./
2) 我还在 apache tomcat 中添加了重写规则
在 $ApacheLocation/conf/context.xml 中
<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />
在 $ApacheLocation/conf/server.xml 中
<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />
但它不适合我。
我将不胜感激。
【问题讨论】:
-
这只是启用 RewriteValve。除此之外,您还必须编写重定向规则以及提到的here
标签: angular tomcat angular6 production-environment