News for hackers. Stuff that matters.
Re:Poor Man's Scalability by bmelton on Saturday October 15, 2011 @03:24PM (#3115552)
With the rise of cloud services, and their relative inability to serve naked domains, there are a couple of easy fixes for this.

The first is to create a vhost in your webserver that serves an index.htm page on your NON-www url. The contents of that page would simply redirect users to the www.yourdomain url.

If that seems like too much work, an even easier fix (truncated for brevity) is to do something like this:

  var url = window.location.href;
  if(url.indexOf("http://www") != 0) {
    window.location.replace("http://www.yourdomain/");
  }
You'd obviously want to capture the remainder of the querystring and add it in, but that's the general idea.
Re:Poor Man's Scalability by sciurus on Saturday October 15, 2011 @04:48PM (#3115755)
A more efficient and search-engine friendly approach is to perform a 301 redirect. For a single site, in Apache this would look like

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example\.com [NC]
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
Re:Poor Man's Scalability by dchest on Saturday October 15, 2011 @03:34PM (#3115582)
Why not plain old HTTP 301/302 redirect?
Re:Poor Man's Scalability by StavrosK on Saturday October 15, 2011 @04:28PM (#3115702)
Please, please use a redirect. The GP's suggestion is not something you want to do.

Even better, just use http://wwwizer.com/ (look for the free redirect service banner on top).

Re:Poor Man's Scalability by jibs on Saturday October 15, 2011 @04:40PM (#3115734)
ooh, this looks really problematic on multiple levels (why wait for JS etc).

A simple solution, which I've used--and I think the OPs situation is similar--is to just have an additional A-record pointed to the ELB, this should work unless the OP is doing something really fancy. No need for route-53, even go-daddy will let you do this.

However, route-53 gives you much better TTL, so if you ever need to re-route..

Re:Poor Man's Scalability by ceejayoz on Saturday October 15, 2011 @10:26PM (#3116356)
ELBs change IP if they have to scale up. You really shouldn't point an A record at one.
Re:Poor Man's Scalability by jibs on Sunday October 16, 2011 @06:35AM (#3117039)
...which is why they recommend you never use the ip, instead AWS provides a hostname, which is invariant...
Re:Poor Man's Scalability by ceejayoz on Sunday October 16, 2011 @01:13PM (#3117718)
Which is why you can't use an A record, as I stated.
Re:Poor Man's Scalability by keltex on Saturday October 15, 2011 @06:15PM (#3115936)
The other thing to do is to specify your canonical page so search engines know to use the www subdomain:

http://googlewebmastercentral.blogspot.com/2009/02/specify-y...