服务器 Gind.cn

服务器问题集锦,包括 Linux(Ubuntu, Centos,Debian等)和Windows Server服务器

Apache httpd后面的Tomcat – 忽略RewriteRule?

我使用mod_proxy在Apache httpd背后有一个相当常见的tomcat应用服务器设置。 我的虚拟主机看起来像这样: <VirtualHost test.example.be:80> ServerName test.example.be RewriteEngine on RewriteRule ^/test/(.*)$ /$1 ProxyRequests Off ProxyPreserveHost On <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://localhost:8181/test/ ProxyPassReverse / http://localhost:8181/test/ </VirtualHost> 在tomcat中部署的应用程序'test'使用一个上下文感知的框架(spring安全性),因此在redirect时预先加载上下文根。 所以,当它redirect到一个名为foo.html的页面时,它会redirect到bleh://test.example.com/test/foo.html。 这个URL不存在,并给出了404。由于我无法控制上下文根的前置,我想我可以解决这个使用mod_rewrite,通过删除上下文根。 不幸的是,这不起作用:就好像RewriteRule完全被忽略。 我注意到一件奇怪的事情:对bleh://test.example.com/test/foo.html的请求甚至不会被转发给tomcat:我从Apache httpd中得到熟悉的404页面。 如果我input任何其他伪造的url,如bleh://test.example.com/jfaklkfdjljfkl,我从tomcat获得404页面。 我希望bleh://test.example.com/test/foo.html可以调用bleh:// localhost:8181 / test / test / foo.html,但显然我在这里丢失了一些东西。 我远离这些事情的专家,所以任何帮助将不胜感激。 UPDATE 我在这个问题上取得了一些进展。 我被告知可以从mod_rewriteloggingdebugging输出,所以我做了这个。 以下是这些日志的相关部分: [12/Oct/2011:10:57:09 +0200] [test.example.be/sid#7b1bc8][rid#820520/initial] (2) […]