Yesterday I had to front an application running on Tomcat with Apache HTTPD server and one of the requirements was to automatically redirect the root URL to the Tomcat's web app context
e.g. http://www.mycompany.com to http://www.mycompany.com/application
Sounded pretty simple and did a Google search, went through few pages that had examples on how to do it but none of them worked. Most involved .htaccess files and using RewiteCond /RewriteRule combinations.
I was getting frustrated with finding a simple solution for the simple problem and after about an hour of searching and trying things I finally found the simple solution that worked. All it needed was the following single line in your VirtualHost section.
RedirectMatch ^/$ /application/
That's it and it will redirect all requests to root URL to the specified sub directory or sub context.
4 comments:
Thank you!! So simple and so hard to find a solution!! :)
after I add this to config file of apache httpd, the homepage is redirected recursively, and end with error. (environment: CentOS 6.5, Apache HTTPd 2.2.15, mod_jk 1.2, Apache Tomcat 7.0.53)
First hit on my search and it did exactly what I wanted, thank you so much!
Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site.Great content as usual.Thank you so much.
Here is sharing Oracle WMS related stuff that may be helpful to you.
Oracle WMS Training
Post a Comment