tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: RewriteRule inside JkMount location
Date Sat, 11 Apr 2009 12:19:47 GMT
J Channel wrote:
[...]

Hi.
Let me jump in here for a while.

First, I think it would be clearer (and certainly more efficient), to 
move your Rewrite rules away from a .htaccess file in docroot, and just 
put them in your main Apache configuration files.
(I suppose that if you have access to the DocumentRoot, you have access 
to the server (or virtual server) *.conf, yes ?)

Second, I personally find another syntax clearer than JkMount, specially 
when you need to combine it with other rules in Apache.
The main reason is that indeed, it is not always very clear which kind 
of "priority" JkMount/JkUnMount directives have, vis-a-vis Apache 
Rewrite, <Location> etc..

So, for example, instead of writing
JkMount /myapp workername
JkMount /myapp/* workername

you can also do it as follows :

<Location /myapp>
   SetHandler jakarta-servlet
   ....
</Location>

This is explained here:
http://tomcat.apache.org/connectors-doc/reference/apache.html

in the section entitled :
Using SetHandler and Environment Variables

Basically, the <Location> section above means that anything 
corresponding to a URI starting with "/myapp" will be passed on to 
Tomcat.  It is thus equivalent to the duo
JkMount /myapp workername
JkMount /myapp/* workername

but, in my view, it gives you more flexibility at the Apache level, and 
also fits better with the Apache "way of things".
I think it makes the respective priorities of mod_jk and RewriteRules 
clearer, because they are the same as what they are in Apache between 
Rewrite and <Location> blocks.
For example, if you load the mod_setenvif module in Apache, you can 
exclude some URI's inside of that location using this kind of thing :

<Location /myapp>
   SetHandler jakarta-servlet
   SetEnvIf REQUEST_URI "\.(css|gif|jpg|js|html?)$" no-jk
   ....
</Location>

meaning that URI's for files starting with "/myapp" but ending in one of 
the extensions above will /not/ be passed to Tomcat (but the rest will).

You can also add a second <Location> like

<Location /myapp/no-tomcat>
   SetHandler none
   ....
</Location>

so that most things starting with "/myapp" will go to Tomcat, except the 
ones starting with "/myapp/no-tomcat".

And of course, you can use <Location>, <LocationMatch>, <Files>, 
<FilesMatch> etc.. to similar effect.

Which seems to me the kind of thing you want.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message