Coding Chronicles: Apache HTTPD Redirect Root URL to Sub Context / Directory
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 contexte.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.
Read full article from Coding Chronicles: Apache HTTPD Redirect Root URL to Sub Context / Directory
No comments:
Post a Comment