如何隐藏在其与Tomcat的URL应用程序上下文? [英] How to hide application context in its URL with Tomcat?

查看:257
本文介绍了如何隐藏在其与Tomcat的URL应用程序上下文?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些在Tomcat中运行的应用程序。每个人都有自己的内容。我迷上他们都与Apache HTTP服务器不同的域名和的mod_jk (查看更多详情这个问题:的如何安装与mod_jk的?上下文引用Tomcat应用程序)。工作得很好,但是当应用程序生成的网页的所有URL仍然有其背景:

I have a number of applications running in Tomcat. Every one has its own context. I hooked them all to different domain names with Apache HTTP Server and mod_jk (see more details at this question: How to mount context-referenced Tomcat application with mod_jk?). Works fine, but when applications generate their web pages all URLs still have their contexts:


  1. http://www.example.com/ 进入 http://www.example.com:8080/my-context/

  2. http://www.example.com:8080/my-context/ 生成一个网页

  3. 该网页所包含的网址 /my-context/some-page.jsf

  1. http://www.example.com/ goes to http://www.example.com:8080/my-context/
  2. http://www.example.com:8080/my-context/ produces a web page
  3. The web page contains URL /my-context/some-page.jsf

我想看看 /some-page.jsf 第三步。什么是重要的是要注意的是,我不能改变应用程序的内部结构。他们是由第三方提供。我所能做的就是配置Tomcat或Apache HTTP服务器。

I would like to see /some-page.jsf in the third step. What's important to notice is that I can't change application internals. They are provided by third parties. All I can do is to configure Tomcat or Apache HTTP Server.

推荐答案

这是有点复杂,但你可以使用URL重写如的 tuckey
重写出站网址,删除/我的上下文preFIX(由出站网址我的意思是你的web应用(S)内生成的URL)。查看该元素的文档在 HTTP ://urlrewritefilter.google$c$c.com/svn/trunk/src/doc/manual/3.2/index.html

This is getting a bit complicated, but you can use a URL rewriter such as tuckey to rewrite outbound URLs, removing the /my-context prefix (by "outbound URLs" I mean URLs being generated inside your webapp(s)). Check out the documentation for the element at http://urlrewritefilter.googlecode.com/svn/trunk/src/doc/manual/3.2/index.html.

为了与你的web应用tuckey的工作,你需要声明添加到您的应用程序web.xml文件。从技术上讲,这意味着修改应用程序,但它是微创。如果你甚至不能触摸web.xml中由于某种原因(不知道为什么),我似乎记得的方式从外部强加在Tomcat中web应用程序的过滤器(不是阀),但远没有这回事pretty

To make tuckey work with your webapp, you would need to add declarations to your apps' web.xml. Technically this means "modifying the applications", but it is minimally invasive. If you can't even touch the web.xml for some reason (not sure why), I seem to recall a way to externally impose a filter (not a valve) on a webapp in Tomcat, but that's going pretty far.

这篇关于如何隐藏在其与Tomcat的URL应用程序上下文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆