1

Is there any way to point multiple sub domains to single webapp in tomcat 7 ?

e.g.

admin.test.com

has already assigned to a webapp. I want to assign

operator.test.com

also to that app. (something like both urls point to same webapp.)

Mayank Pandya
  • 1,593
  • 2
  • 17
  • 40

2 Answers2

2

On the top of my head I can think about the following ways.

  1. Create copy of your war file, give it different way and put under TOMCAT_HOME/webapps. Actually this means that you will have 2 applications installed from the same code base. However if your application uses only DB to store state this is probably not a problem.
  2. If you are on Unix create softlink into webapps directory to your war file. So, you will get the same solution as in #1 but without copying file.
  3. Create 2 contexts that point to the same file. For details see this or similar document: http://tomcat.apache.org/tomcat-5.5-doc/config/context.html#Automatic_Context_Configuration
  4. Use alias. Here is document that explains how: http://tomcat.apache.org/tomcat-5.5-doc/config/host.html#Host_Name_Aliases
AlexR
  • 114,158
  • 16
  • 130
  • 208
  • There is 2 different pages that I want to show based on URL for example http://operator.test.com/ shows operator.jsp and for http://user.test.com/ shows admin.jsp but both contains in same webapp. 1. is not posible. in this cases can 4th work? – Mayank Pandya May 26 '13 at 22:12
1

There is a much easier way to do this:

  <Host name="domain1.com" ...>
    <Alias>www.domain1.com</Alias>
    <Alias>domain1.net</Alias>
    <Alias>www.domain1.net</Alias>
    ...
   </Host>
dmcqu314
  • 875
  • 11
  • 29