Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mod_jk conflicts with mod_rewrite

I've got an Apache and Tomcat running and I use mod_jk to bind them. I have a Tomcat worker called "tc1" and the following setup on my 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.

Now I want to use mod_rewrite and do something very simple such as:

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_rewrite do not end up into mod_jk.

I've read the Apache Tomcat Connector documentation and tried all of the JkOptions but nothing changed.

Does anyone know how to solve this?

Does the mod_jk and mod_rewrite load order and declarations ordering play any role in URL processing?

thanks

like image 817
cherouvim Avatar asked Aug 17 '09 18:08

cherouvim


1 Answers

That's odd, because by default a RewriteRule sends 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 /foo and the the request for /bar also?

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.

like image 174
skaffman Avatar answered Sep 18 '22 20:09

skaffman