.htaccess - tomcat项目中的URL重定向

标签 .htaccess tomcat tuckey-urlrewrite-filter

我正在使用 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/

相关文章:

apache - 拒绝除 Apache 中的一个配置文件之外的所有配置文件

spring - 将Spring Boot RESTful Web Service部署到Tomcat时,Web.xml仍然丢失

java - tuckey urlrewrite 返回 404 未找到

regex - 使用 Tuckey URL Rewrite 添加文件扩展名

java - 将此 Apache Rewrite 规则转换为 tuckey URLRewriteRule

php - Opencart SEF 破坏了相关链接

php - .htaccess 不工作

apache - 将 www.subdomain.example.com 重定向到 subdomain.example.com

tomcat - 在 Amazon EC2 中使用 tomcat 的 Spring 安全登录 https 无法正常工作

java - HstSiteConfigurer : ComponentManager initialization failed