Forum Moderators: phranque

Message Too Old, No Replies

Redirect .html request from Apache server to Tomcat server

.htaccess .html request redirect

         

anoopsp

11:25 am on Jan 12, 2011 (gmt 0)

10+ Year Member



Hi,
Our web server is a combination of Apache http server and Tomcat server. When ever any request comes, first it will handled by Apache server.If it is type of .html or .htm or .log etc., then the Apache server will process it. If the request is type of .jsp, Apache will pass the request to Tomcat server and Tomcat server will process the request.

I deployed a java web application in Tomcat which having some servelt mapping for .html and .log. Since the Apache http server having the configuration to handle .html, the given request is not passed to Tomcat server.

I checked with our Admin, they confirmed me that, i can create a .htaccess file in the root directory, which having the configuration to ignore or redirect the .html request from being handled by Apache http server.

Is any one know what is the command/configuration i need to add in the .htaccess file ?

Since we do not have any admin access to server, it is impossible to do some techniques like mod_jk or mod_proxy :(

jdMorgan

5:20 pm on Jan 14, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The answer depends on whether mod_jk or mod_proxy is already being used to reverse-proxy back-end requests at the server config level. If so, then it may be "too late" to change this behaviour, because .htaccess won't execute until mod_jk or mod_proxy has already proxied the request to your Tomcat server.

If this is the case, then it may be necessary to use different "filenames" for the .html URLs that need to be handled differently.

If not, then a simple rewriterule can be used to pass some .html URLs to the back-end. An example for a single "special" URL-path would be:

RewriteRule ^special-html-URL-path$ http://tomcat-server-domain-or-IP-address/special-html-URL-path [P]

If you do not already have other working rewriterules in your .htaccess file, then you will need to 'set up' mod_rewrite, using either both of the following lines, or only the second line. The only way to tell if both lines are needed (or allowed) is to test:

Options +FollowSymLinks -MultiViews
RewriteEngine on

Jim