I have deployed a tomcat application and made the necessary configurations to web a server (for eliminating port etc.).

I can access the application following way


But I would like to access the app even when user enters

http://www.domain.com (just url, no app name)
http://domain.com (just domian name)

I am new to Apache configurations, any pointers, or samples would greatly help.

I thought "proxy pass" would resolve...
Do I need to look for rewriting rules or any other?


I have solved this by putting an index.html file into the webapps/ROOT folder containing a normal HTML redirection:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <meta http-equiv="REFRESH" content="0;url=./appname/"></HEAD>

You could deploy your application as the ROOT webapp in Tomcat in order to eliminate the prefix you still have. Just unzip your app to the $CATALINA_HOME/webapps/ROOT folder or - if deployed as zipped .war file - just rename your file to ROOT.war when putting it into the webapps folder. It will then be available without application prefix.

Regarding your domain names with / without "www" part: If you are using Apache in front of Tomcat, then the mod_rewrite reference documentation has a good section describing canonical hostnames.


For those who may need solution, I just added the following to httpd.conf and it is working fine for my issues:

RewriteEngine on  
RewriteCond %{HTTP_HOST} !^www\. [NC]  
RewriteCond %{HTTP_HOST} !^$  
RewriteRule ^/?(.*) http://www.%[HTTP_HOST}/$1 [L,R,NE]  

ProxyPass         /appname  http://localhost:8080/appname  
ProxyPassReverse  /recsconnect  http:...  
ProxyPass / http...  
ProxyPassReverse / http....  

I forgot earlier adding last two lines.


Another option worth considering, is the UrlRewriteFilter. Especially useful if you already know mod_rewrite but don't want to use apache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.