我有一个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重写阀,如下所示:
在 的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 /卡塔利娜/ 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,但它的行为方式相同。