【问题标题】:Tomcat url redirection (not root)Tomcat url 重定向(非 root)
【发布时间】:2016-09-30 11:00:46
【问题描述】:

是否可以重定向特定的url

http://10.99.77.170:8080/web/userview/MainView/_/inboxing

http://10.99.77.170:8080/web/userview/MainView/_/my_docs

它不应该重定向 url 之类的

http://10.99.77.170:8080/web/userview/MainView/_/inboxing?something=sth

由于我正在使用一个不允许我这样做的框架,是否可以使用运行它的 Apache Tomcat 来制作和重定向? 感谢您的任何建议。

【问题讨论】:

  • 是的,您可以这样做。你用的是什么框架?您想编写自己的代码吗?您想使用可以执行此操作的现有工具吗?
  • 您好,谢谢您的提问,我正在使用Joget Enterprise。我试过 zlatkovic.com/httpredirectfilter.en.html ,但它并没有像我需要的那样真正工作,而且它正在让我的服务器发疯(300+ % CPU 使用率 [4core])。你有什么提示我怎么能完成这个重定向?

标签: tomcat war url-redirection


【解决方案1】:

进行条件重定向的最简单方法是使用tuckey's url-redirect 项目。它被打包为一个 JAR 文件,您可以将其放入 Web 应用程序的 WEB-INF/lib/ 目录并使用 WEB-INF/lib/web.xml 和外部配置文件进行配置(将传入 URL 映射到传出 URL)。

他们的网站上有大量关于如何设置这些映射的文档。你应该能够想出一个规则来做你想做的事情。像这样的:

<urlrewrite>
  <rule match-type="wildcard">
    <!-- The 'condition' is what prevents redirection when there is a query string-->
    <condition type="query-string" operator="notequal"></condition>
    <from>/userview/MainView/_/inboxing</from>
    <to type="redirect">/userview/MainView/_/my_docs</to>
  </rule>
</urlrewrite>

【讨论】:

    猜你喜欢
    • 2023-04-01
    • 2010-11-24
    • 1970-01-01
    • 2021-10-11
    • 1970-01-01
    • 1970-01-01
    • 2021-06-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多