I was talking to Roy Leban the other day about how a particular domain registrar of his makes it check-box trivial to redirect from a naked domain (say example.com) to www.example.com, but doesn’t do anything whatsoever to redirect from example.com/someurl to www.example.com/someurl. I was teasing him about needing to get a real domain registrar, but it turns out he has a really slick hack to manage the redirect on the www.example.com side (which happens to be hosted on Google App Engine) since App Engine isn’t cool with naked domains.
What he does is this:
- checks the box on his domain registrar to forward from example.com/* to www.example.com/
- once the user’s web browser arrive at www.example.com, he checks the HTTP Referer1 header to see if the user came from example.com/something, and, if so,
- redirects the user one more time to www.example.com/something based on the Referer (in this case example.com/something).
I’m not sure that solution would have ever occurred to me, but I love it for the hack value.