jQuery in Action, 2nd edition*
The moose likes Tomcat and the fly likes Tomcat on Windows - rewriting or similar based on URL? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat on Windows - rewriting or similar based on URL?" Watch "Tomcat on Windows - rewriting or similar based on URL?" New topic
Author

Tomcat on Windows - rewriting or similar based on URL?

Alex Elderfield
Greenhorn

Joined: Oct 31, 2012
Posts: 1
Hi,

I'm new to Tomcat (background in C# and IIS) and trying to achieve the following using Tomcat 5.5 on Windows.

- http://*.URL1.com and http://*.URL2.com point to the same Java app in Tomcat.
- All image requests from *.URL1.com should be served from /images1/...
- All image requests from *.URL2.com should be served from /images2/...
- All other files shared between the two URLs.

Obviously there's two parts to this:
1. serving the right image folder depending on the URL header
2. the * could be a number of different things (i.e. a number of different sub domains)

I'd rather use the wildcard (i.e. not have to specify all the sub domains).

Any suggestions need to be within the scope of Tomcat on Windows - I've inherited the application and don't have scope to change OS or server technology.

Thanks!

Alex
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16158
    
  21

Welcome to the JavaRanch, Alex!

Although you could probably create a custom Valve in Tomcat to do all that, it's generally easier to delegate the process of re-routing and re-writing to a server where you can just code rules instead of writing and debugging code. One of the more popular ways of doing that is to front Tomcat with the Apache HTTPD server using mod_proxy and mod_rewrite.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
Consider Paul's rocket mass heater.
 
subject: Tomcat on Windows - rewriting or similar based on URL?