views:

188

answers:

2

I'm trying to create a series of sites that all run as one application, but have different designs (to localise them).

My idea is to map separate domain names to the one site. E.g: www.mysite1.com maps to www.mysite.appspot.com/mysite1 and www.mysite2.com maps to www.mysite.appspot.com/mysite2

I'm guessing that there must be a url pattern or something to pass a servlet the name of the site from web.xml? I'd like urls such as www.mysite.appspot.com/mysite1/forumpost/3/ to be able to be handled by the same servlet as www.mysite.appspot.com/mysite2/forumpost/3/. Ideally I'd like to pass the site name as a parameter to the servlet.

Surely there is someone that has done this before, or some standard way of doing this? I've got a fuzzy idea about parsing the url to take the site name out of it, but I'm pretty new to servlets etc and thought that someone might be able to shed some light on this situation.

Thanks!

A: 

Try using a javax.servlet.Filter and forwarding to the language specific pages based on the HTTP request header 'Accept-Language' (I think that's the one). You can get at that with a call to javax.servlet.HttpServletRequest.getHeader(String).

This way your site has a single URL and the separation into language specific pages is handled internally.

Nick Holt
Thanks, but I'm actually only dealing with english, and the sites are separated by viewer's location (within just one country). I want to create it so that I can run multiple community websites, so I want to have different urls for each site...
Louis Sayers
+1  A: 

You can't map your own subdomains of appspot.com apps (eg, foo.mysite.appspot.com), but you can map arbitrary domains to your app directly, such as www.mysite1.com and www.mysite2.com - just add them all as aliases to your Google Apps account, and then map them to your App Engine app. Once you've got that done, you just need to check the content of the Host header in your app to route requests to the appropriate handlers (or otherwise vary the content you return).

Nick Johnson
Yes, thanks for that :)
Louis Sayers