[users@httpd] Tip for Apache, Tomcat on 2 differents boxes and using a separate document tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux