Getting jque.re off the apex

I am just going to briefly discuss how I configured a project of mine called Handpicked jQuery Plugins, and how I leveraged Github Pages to host it. I will also briefly mention an excellent technique to redirect your visitors away from an apex domain, and on to a sub-domain, using a pay-as-you go service called NearlyFreeSpeech.

Default configs

An apex domain is the raw domain you purchase from a registrar. In my case case jque.re. Most hosting packages have a sub-domain called www that has no purpose whatsoever, and is only there because of an anti-pattern.

The mistake some people make is never investigating this default set-up, and never bothering to research their DNS config. For years, I got by, never having to care about my DNS config, until recently.

Going it alone

There are massive SEO benefits to having DNS configured correctly, as-well as massive performance benefits. Asking on forums how to configure servers, or asking tech support agents for help doesn't scale. You have to dig deep and figure out this stuff alone, because one day, it will pay off.

In the last few years, as I started poking around with servers a lot more, I realized that if DNS goes overlooked for too long, you're going to run into problems. DNS needs to be maintained, and also periodically checked for errors, just as you would check for 404s on your website.

The initial grunt-work of figuring out DNS all by yourself pays massive dividends. Today I decided to use my knowledge of DNS and servers to optimize a website I was having problems with, in this case jque.re.

SEO problems

So the problems were numerous. The main problem was SEO. Google Webmaster Tools was giving out about far too many things. My SEO was really messy, and there was too many redirects, subdomains, and crawl errors.

On top of this, I just got news that Github Pages ( which hosts the site) switched to a new Fastly CDN. I wanted to make full use of the Fastly CDN, so I had to move the site off the apex domain.

It's not optimal to have all your content served from the apex, because if those IPs are being DDOS'd or if they simply don't work, or are shut down, your site goes down too, and your users bounce and hate you. You might even lose money, and could end up homeless as a result :) So what do we do?

The fix

CNAMEs to the rescue! So with a CNAME, we can point a sub-domain at another domain (which points to the most up-to-date IP being used). You don't have to manually configure the IP anymore, which is a lot more optimal.

Github says we should use an exotic, and not widely supported DNS feature called ALIAS if we're going to be serving from the apex and still use the CDN. This is a bit hacky, so I would avoid doing this. Remember the www sub-domain we talked about earlier? Let's point that at our fancy new Fastly-powered Github site.

In our case www.jque.re is pointed at jquer.github.io

Non-WWW to WWW

Since inevitably, users will type in jque.re into the address bar (omitting the www), they're going to arrive at the apex domain, which should be doing something important. Don't leave it mis-configured, and don't be a douchebag and point it at 1.3.3.7 (this is not funny BTW).

What we can do is get our hands on a really cheap Apache server, and handle any requests to the apex appropriately. An ideal service for this is Nearly Free Speech (NFS). Here we choose a bare-bones server:

Nearly Free Speech are pay-as-you-go, so we only pay for what we use. Since we are merely rewriting non-www to www, this costs very little each year.

If you decide to do this, don't forget to create an alias for the domain you want 'wwwized'

In our NFS root, we add a simple HTACCESS rule:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

That's all we need. This works for any domain you attach to NFS. There are some sites that offer this service for you, like wwwizer, but I would not rely on them. Infact I have tried all the other ones, and witnessed down-time on each one.

Conclusion

After doing all this, Google Webmaster Tools loves me. It reports no problems, or crawl errors. My users benefit from a fast site with a good uptime record, and the site is also easier to maintain, as I know where things could go wrong, and how to fix them much faster.

Noteworthy:

Comments? Feel free to give feedback on the Designer News thread.