如何在 Apache 中为 Tomcat 创建替代 URL / 别名(仅对用户可见)

How to create alternative URL / Alias in Apache for Tomcat (only visible to the user)

我正在使用 Apache2 -> mod_jk -> Tomcat7

我正在使用以下 URL 调用 JSF 网络应用程序:http://server/foo

现在,我也喜欢用URL来称呼它:http://server/bar

foo 的调用应始终更改为 bar

由于 Tomcat 要求并与 /foo 相关,任何 JSF request.getContextPath() returns /foo。因此,后续页面调用会导致浏览器网址包含 /foo 而不是 bar.

What do I need to change in order to keep tomcats foo-paths while the user sees bar-paths in the browser?

这是我目前的配置:

/etc/apache2/conf.d/test.conf

Alias /foo "/original/path"
RewriteEngine on
RewriteRule "/bar(.*)" "/foo" [PT]
<Directory "/original/path">
.... 
</Directory>

/.../tomcat7/conf/Catalina/localhost/test.xml

<Context path="/foo" ...></Context>
  1. 需要 foo.xml tomcat7/conf/Catalina/localhost
  2. ...

    别名 /foo“/original/path” 重写引擎开启 RewriteRule "/bar(.*)" "/foo$1" [PT] ....