如何隐藏在其与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:
-
http://www.example.com/
进入http://www.example.com:8080/my-context/
-
http://www.example.com:8080/my-context/
生成一个网页 - 该网页所包含的网址
/my-context/some-page.jsf
-
http://www.example.com/
goes tohttp://www.example.com:8080/my-context/
-
http://www.example.com:8080/my-context/
produces a web page - 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.