tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pete Storey <>
Subject mod_jk and mod_rewrite
Date Mon, 05 Nov 2012 16:58:34 GMT

I've got what I think is a pretty normal setup, where I have an Apache
server serving some content for a website, and using mod_jk to connect to
Tomcat running on another server.  My problem is that I'm also trying to
use mod_rewrite to ­ err, rewrite URLs.  In short, if I do this the
'normal' way and include rewrite directives in the .htaccess file for the
website, it doesn't work and they are ignored, however if I put them in
the main httpd.conf file, before the JkMount directive, then they do work.

This appears to be a case of a problem with the order in which
modules/filters hook into Apache and are run;  I have looked at the
documentation and searched about for answers on this but found nada.  I've
tried using the various JkOptions setups but it doesn't seem to achieve

In my httpd.conf, mod_rewrite is loaded before mod_jk though I don't think
this matters especially.

Some potentially relevant config -

- in httpd.conf

<Directory />
    Options FollowSymLinks
    AllowOverride None

<Directory "/var/www/html">

    Options -Indexes +FollowSymLinks

  <LimitExcept GET HEAD POST>
     deny from all

    AllowOverride All

    Order allow,deny
    Allow from all


AccessFileName .htaccess

JkWorkersFile /etc/httpd/conf/
JkShmFile     /var/log/httpd/mod_jk.shm
# Rotate weekly
JkLogFile     "|/usr/sbin/rotatelogs /var/log/httpd/mod_jk.log 604800"
JkLogLevel    warn
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
#JkOptions     +ForwardURIProxy

- Inside the (included into httpd.conf) virtual host.conf file

    RewriteEngine on
    Include vhosts/htaccess/mysite.htaccess

# Mount all to Tomcat
    JkMount /* mysite
# Handle images locally
    JkUnMount /*.gif mysite
    JkUnMount /*.jpg mysite
    JkUnMount /*.jpeg mysite
    JkUnMount /*.png mysite

- Inside the my site.htaccess file (example line)

# McAfee secure image
RewriteRule ^/assets/cached/mcafee\.png /assets/php/mcafeeimage.php [L,NC]

Now this all works fine - except that I have to have a file which is
directly included into the httpd.conf, and which thus requires the server
to be restarted every time you want to make a change.  On top of that, if
there is a problem in the file, then the whole server will fail to start,
which is clearly far from ideal.

Is there a way to hook in the RewriteEngine in .htaccess rather than
having to include them like this?  I can't believe I am the first person
to discover this/have this setup?

Many thanks

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message