【发布时间】:2015-04-30 07:31:31
【问题描述】:
我有一个 AngularJS webapp 和 Jersey 后端。我需要设置 URL 重写,所以除了给定的异常之外的所有内容都将被重写为 Angular 的 index.html。
例如:
http://my.domain.com/about will be rewritten
http://my.domain.com/photos/photo1.jpg will NOT be rewritten (file photo 1 exists)
http://my.domain.com/rest/myservice will be NOT be rewritten (it is a call to REST service)
我已经如下设置了 Tomcat 8 URL Rewrite Valve:
在 conf/server.xml
中<Host name="my.domain.com" appBase="webapps/MyDomainServer" unpackWARs="true"
autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />
<!-- access logging, aliases,...-->
</Host>
在 conf/Catalina/my.domain.com/rewrite.config
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} ^/rest.*
RewriteRule ^ - [L]
RewriteRule ^ index.html [L]
Tomcat 忽略了我的重写设置,没有重写任何内容,日志中没有错误/异常。我究竟做错了什么?提前致谢。
我尝试将 RewriteValve 移动到 META-INF 中的 config.xml 并将配置重写为 WEB-INF,但它的行为方式相同。
【问题讨论】:
-
你能为stackoverflow.com/questions/66472682/…提供解决方案吗
标签: java angularjs apache url-rewriting tomcat8