apache mod_jk 与 mod_rewrite 冲突
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1289653/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mod_jk conflicts with mod_rewrite
提问by cherouvim
I've got an Apache and Tomcat running and I use mod_jkto bind them. I have a Tomcat worker called "tc1" and the following setup on my VirtualHost:
我有一个 Apache 和 Tomcat 正在运行,我mod_jk用来绑定它们。我有一个名为“tc1”的 Tomcat 工作器,我的 Tomcat 上有以下设置VirtualHost:
JkMount /* tc1
JkUnMount /*.png tc1
JkUnMount /*.gif tc1
JkUnMount /*.css tc1
JkUnMount /*.js tc1
That way Tomcat serves all requests apart the ones for static files.
这样 Tomcat 可以处理除静态文件之外的所有请求。
Now I want to use mod_rewriteand do something very simple such as:
现在我想使用mod_rewrite并做一些非常简单的事情,例如:
RewriteEngine On
RewriteRule ^/foo$ /bar [L]
to rewrite the dynamic pageview at "/foo" to "/bar", but it doesn't work because all urls processed by mod_rewritedo not end up into mod_jk.
将“/foo”处的动态浏览量重写为“/bar”,但它不起作用,因为所有 url 处理的 urlmod_rewrite都不会最终变成mod_jk.
I've read the Apache Tomcat Connector documentationand tried all of the JkOptionsbut nothing changed.
我已经阅读了Apache Tomcat 连接器文档并尝试了所有JkOptions但没有任何改变。
Does anyone know how to solve this?
有谁知道如何解决这个问题?
Does the mod_jkand mod_rewriteload order and declarations ordering play any role in URL processing?
是否mod_jk和mod_rewrite加载顺序和声明顺序发挥URL处理任何作用?
thanks
谢谢
回答by skaffman
That's odd, because by default a RewriteRulesends a client-side redirect, so the client should make a second request to /bar which should be caught by your JkMount. Does your access log show show the request for /fooand the the request for /baralso?
这很奇怪,因为默认情况下 aRewriteRule发送客户端重定向,因此客户端应该向 /bar 发出第二个请求,该请求应该由您的JkMount. 您的访问日志显示是否也显示了请求/foo和请求/bar?
Try this rule instead:
试试这个规则:
RewriteRule ^/foo$ /bar [PT,L]
The "PT" means "pass-through", and is a rewrite bodge which allows you to mutate the URL in situ and lets other modules get a look in, without sending a redirect.
“PT”的意思是“pass-through”,是一个重写bodge,它允许你在原地改变URL并让其他模块查看,而无需发送重定向。

