我正在使用 tomcat 7.0 做一个网络项目。我想将一个页面重定向到另一个页面。
我可以在 tomcat 中使用 .htaccess 文件吗?如果能用,我该怎么办?
或者我可以在 web.xml 中配置吗?
非常感谢您的帮助。
最好的问候,
索克利
最佳答案
mod_rewrite
只是一个 Apache 模块,但您可以使用 UrlRewriteFilter
在 Tomcat 中。
这样的规则应该适用于 /WEB-INF/urlrewrite.xml
:
<urlrewrite>
<rule>
<note>
The rule means that requests to /page-one/ will be redirected to /page-two/.
The url will be rewritten.
</note>
<from>/page-one/</from>
<to type="redirect">/page-two/</to>
</rule>
</urlrewrite>
关于.htaccess - tomcat项目中的URL重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19761841/