Apache Tomcat URL without app name
Solution 1
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">
<html>
<head>
<title>appname</title>
<meta http-equiv="REFRESH" content="0;url=./appname/"></HEAD>
<body>
</body>
</html>
Solution 2
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.
Solution 3
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.
Related videos on Youtube
Comments
-
user79333 over 1 year
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
http://www.domain.com/appname/
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?