0

I've apache2 and tomcat6 running on port 80 on ubuntu server 9.10. I've a registered domain name and I'll access the jsp index page navigating to http://abc.mydomain.com. The page is under tomcat_home/webapps/myapp and the below are tomcat virtual hosting in server.xml file:

<Host name="abc.mydomain.com" debug="0" appBase="webapps" unpackWARs="true">
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="virtual_log1." suffix=".log" timestamp="true"/>
<Context path="" docBase="/usr/share/tomcat/webapps/myapps" debug="0" reloadable="true"/>
</Host>

Recently a new domain has been bought(xyz.mydomain.com) and I'm asked to do the virtual hosting so that the new domain name directly points the page "admin.jsp" which is located under 'tomcat_home/webapps/myapps/WE-INF/js/'(can be accessed pointing to http://abc.mydomain.com/admin). How could I do this?

If I type http://abc.mydomain.com/admin I'll get the page what I wanted. I should access this page just by typing http://xyz.mydomain.com. Is there any url redirection or I could define any alias in tomcat virtualhosting?. Need help...

user53864
  • 1,653
  • 8
  • 36
  • 66

1 Answers1

1

Try nesting the admin web app via a <Context> element in the server.xml within an additional

 <Host name="xyz.mydomain.com" ...>

In addition to your current

<Host name="abc.mydomain.com" debug="0" appBase="webapps" unpackWARs="true">
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="virtual_log1." suffix=".log" timestamp="true"/>
<Context path="" docBase="/usr/share/tomcat/webapps/myapps" debug="0" reloadable="true"/>
</Host>

add this

<Host name="xyz.mydomain.com" appBase="webapps"> 
    <Context path="" docBase="/usr/share/tomcat/webapps/myapps"/> 
      </Host> 

If path is set to "" then you can get the app at the ROOT context, like xyz.mycompany.com instead of xyz.mycompany.com/myapps

Now move your admin.jsp to the root of the web app, so move it out of 'tomcat_home/webapps/myapps/WE-INF/js/ into

/usr/share/tomcat/webapps/myapps

and finally in the web.xml of your myapps web app, add an entry to make admin.jsp the home page like so

<welcome-file-list>
    <welcome-file>admin.jsp</welcome-file>
</welcome-file-list>
JoseK
  • 455
  • 6
  • 13
  • one doubt!. if the welcome page is admin.jsp won't it affect the other domain name(abc.mydomain.com)? – user53864 Dec 16 '10 at 12:03
  • yes it could. since the web app is the same, so you might have to try and duplicate your web app. not a good idea - I admit – JoseK Dec 16 '10 at 12:27