Mar 17, 2011

f Comment

301 Redirect a Naked Domain To a Subdomain in MINUTES!

Amazon How do you 301 redirect a naked domain to some sub domain, most commonly www, so that when someone goes to yourDomain.com they'll be 301 redirected to www.yourDomain.com?

For those who don't understand what 301 redirect is here's a quick answer. When your webpage has been moved to a new place you usually want to set your web server to tell whoever accessing the old webpage that it's been moved to a new place permanently. This behavior is realized with a 301 redirect.

If the client is a search engine, for example, they'll know your web page has been moved permanently.

ANSWER
There are at least two ways to 301 redirect a naked domain to a subdomain:

1: In your domain's DNS setting add an 'A record' with host @ and configure your web server accordingly.

2: Have your domain name registry do that for you.

Below we'll look at each method in more detail and also look at the pros and cons of each!

1. Configure DNS Setting
In your domain's DNS setting add an 'A record' with Host set to @ and set it to point to your machine's IP. If you use GoDaddy.com here's a screen shot of that setting:

GoDaddy DNS Manager A Host Setting For Naked Domain

This setting makes sure the naked domain, yourDomain.com, goes to your server. Once you finish the setting you may need to wait for up to one hour for the setting to take effect.

In some domain registrar the way you do this setting may be different. For example they may ask you to leave the Host field empty to indicate that it's a naked domain.
Next we need to configure your web server to 301 redirect the HTTP request for the naked domain to any subdomain you want such as www. This depends on the capabilities of your web server but it should have this feature. For example if you use Nginx and your domain is mensfashionforless.com then here's what you put in your web server's configuration file:
server {
  listen 80;
  server_name mensfashionforless.com;
  rewrite ^/(.*) http://www.mensfashionforless.com/$1 permanent;
}
This rule simply means that the web server listens on port 80 and it handles HTTP requests for 'mensfashionforless.com' by 301 redirecting it to 'www.mensfashionforless.com'.

In fact, this rule exhibits a great benefit: You have total control over the destination of the redirect. In this case your web server will redirect http://mensfashionforless.com/some-page.html to http://www.mensfashionforless.com/some-page.html. You have total control.

2. Ask Your Domain Name Registry to Do That
Have your domain name registry (e.g. GoDaddy) do that for you (read http://www.printfection.com/help/article.php?articleid=41 if you use GoDaddy). Basically you'll be able to pick 'Forward Domain' option to forward your naked domain, or non-www domain, to any domain you'd like via 301 redirect. Typically you'd forward your naked domain to your www domain but you can actually forward it to any domain you want.

This depends on the abilities of the registry you registered your domain with but they usually have this functionality.

This way presents limited functionality because you might not be able to forward your old path to your new path. For example you might want to redirect http://mensfashionforless.com/some-page.html to http://www.mensfashionforless.com/some-page.html but whether you can do this depends on the domain registry you use.

In addition your domain registry, although unlikely, can alter their functionality any time they want. You are basically at their mercy.

If you have any questions let me know and I will do my best to help you!
Please leave a comment here!
One Minute Information - by Michael Wen
ADVERTISING WITH US - Direct your advertising requests to Michael