Jboss + mod_rewrite =

apache-2.2jbossmod-jkmod-rewrite

I have 2 servers, Apache and Jboss. Using JKmount .war files are mounted and present a complex site.

eg:

JkMount /directory/* ajp13
Alias /directory /jboss/server/default/deploy/directory.war
<Directory  /jboss/server/default/deploy/directory.war>
  Order allow,deny
  allow from all
  Options -Indexes
</Directory>
<Directory  /jboss/server/default/deploy/directory.war/WEB-INF>
  deny from all
</Directory>

I would like to use mod_rewrite on the Apache side to alter the URLs returned by mod_jk.

eg:

RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^192.168.1.1$
RewriteRule /.* http://server.example/redirect.html [R=301,L]

Currently the above code only affects the images returned by Apache and not the pages returned by mod_jk.

Is this possible?
How is it done?

There is a similar question asked at StackOverFlow however given a choice if it is possible I would like to handle this internal to Apache and not alter the Jboss configuration.

The server is OpenSuse 11.1 and I suspect there maybe some module precedence order issues however I have not been able to confirm this.

Examples of URLs would be:

http://site.example/directory/index.jsp
http://site.example/foo/other.html

In this example the first URL is mounted in mod_jk using the directives listed in the config above and would NOT be re-written by mod_rewrite. The second URL is a normal directory in the Apache site and is rewritten correctly.

Thanks All

Best Answer

After a long search I have found the answer to this one.

The rewrite directive must be placed globally for the (virtual) host not in the or in a .htaccess. Apache appears not to actually parse those files as the files served out of mod_jk are not part of that structure; which makes sense if you think about it. It will however apply mod_rewrite rules that apply to the entire host.

Related Topic