Tomcat6 map subdomain to particular directory under web root

View: New views
3 Messages — Rating Filter:   Alert me  

Tomcat6 map subdomain to particular directory under web root

by kazukin6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

server.xml
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
        <Alias>w1.localhost</Alias>
      </Host>

Using alias "w1.localhost" maps subdomain to web root directory
Is there any trick to map w1.localhost to localhost/w1 directory?

RE: Tomcat6 map subdomain to particular directory under web root

by Caldarale, Charles R :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> From: kazukin6 [mailto:coolwhiff@...]
> Subject: Tomcat6 map subdomain to particular directory under web root
>
> server.xml
>       <Host name="localhost"  appBase="webapps"
>             unpackWARs="true" autoDeploy="true"
>             xmlValidation="false" xmlNamespaceAware="false">
>         <Alias>w1.localhost</Alias>
>       </Host>
>
> Using alias "w1.localhost" maps subdomain to web root directory
> Is there any trick to map w1.localhost to localhost/w1 directory?

You can use Tuckey's URL rewrite filter (http://tuckey.org/urlrewrite/) or you could use virtual hosts: instead of the <Alias>, define a second <Host> with an appBase pointing to the desired directory.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@...
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


RE: Tomcat6 map subdomain to particular directory under web root

by kazukin6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Caldarale, Charles R wrote:
You can use Tuckey's URL rewrite filter (http://tuckey.org/urlrewrite/) or you could use virtual hosts: instead of the <Alias>, define a second <Host> with an appBase pointing to the desired directory.
 - Chuck
Chuck, thanks a lot!
1)  I didnt manage to get the second host working, tomcat just won't find any pages/resources and returns empty pages. Adding context element         <Context path="" docBase="\ROOT\w1" reloadable="true"/>  seems to fix that problem, but in this case it looks like it's working in separate context (none of the java classes from WEB-INF/classes can be used)
2) Tuckey's URL rewrite  does work! But I'm not sure about performance overheads, compared to using Apache WebServer with Virtual Hosts.
For those who concern, here is the sample rule (from urlrewrite.xml)
    <rule>
        <note>
            subdomains redirect
        </note>
        <condition name="w1.localhost" operator="equal" type="server-name">w1.localhost</condition>
        <condition name="admin" operator="notequal" type="request-uri">/admin/(.*)</condition>
        <condition name="w1 cyclic redirection" operator="notequal" type="request-uri">/w1/(.*)</condition>
        <from>^/(.*)</from>
        <to>/w1/$1</to>
    </rule>

LightInTheBox - Buy quality products at wholesale price