httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jean-Marc Jacquot <jean-marc.jacq...@investis.com>
Subject [users@httpd] Tip for Apache, Tomcat on 2 differents boxes and using a separate document tree
Date Wed, 07 Dec 2005 15:19:23 GMT
Just a tip that I've found and wanted to share with the community, hope 
it might help people in the same situation.

Regards, Jean-Marc.



Context
-------

Apache is not on the same box as Tomcat, mod_jk is using a unicast 
socket to communicate through ajp
Apache is serving a htdocs/ directory with static files only
Tomcat is serving a webapp/ directory with .jsp files only

Problem description
-------------------

The following rewrite rule was written to solve a problem when a 
directory wasn't existing on Apache but on Tomcat
and the end client was requesting it via http://url/ without 
filename.jsp behind, Apache would return a 404 instead
of trying to forward it to Tomcat, thing that would not happen if the 
directory was existing on the Apache side as
the DirectoryIndex set with default.jsp would trigger the forward.

The problematic case is you've dir1/ on the Tomcat directory tree but 
not on Apache, if you call GET /dir1/, Apache will return 404
without the rewrite rule.

Note that this rule depends on DocumentRoot, so if you're using it 
within a VirtualHost, check that the DocumentRoot is set
(NB: It doesn't work with the VirtualDocumentRoot directive)

Solution
--------

RewriteEngine on
    RewriteCond %{REQUEST_URI} /$
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
  RewriteRule ^/(.*) /$1default.jsp [R]

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message