0

I have google app engine application working on my naked domain but I can't find any tutorials on how to redirect the non naked (www) sub domain to the naked domain.

It seems only like they build in the other way, naked to www.

Can anyone assist with how I can do this?

1 Answer 1

2

I cannot answer specifically to Google app cloud, but here is what is happening behind the scenes.

When you go to www.domain.com there is a DNS lookup. So you must first have dns for www.domain.com, pointing at the same server, servers (if you are doing round robin dns load balacing), or load balancing ip (if you are load balancing somewhere else) as domain.com. You didn't say, but I imagine this is already working and all you want to do is the "redirect".

To know that a client is going to www.domain.com instead of domain.com, you need to inspect the Host header in the HTTP Request. This is at Layer 7 of the traditional OSI model. If your app cloud has a device like a multilayer firewall or reverse proxy before the server, you could read this header there and then reply to the client with a 302 Location domain.com, which will redirect them as you like. Otherwise, you can also do this on your web server. The pseudo code would be like:

if Host equals www.domain.com
  then generateHTTPResponse(302,Location=domain.com)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .