Redirect non-www domain to www using htaccess for seo

If you own a website running under your own domain, then you probably already understand the importance of SEO. One of the easiest and most important things to improve your SEO health is to avoid duplicate links in your content. So, make sure that you are not serving both and links separately. Ideally you should be 301 redirecting one to another (for understanding different redirects, check out seomoz article) to not dilute your SEO karma between www and non-www links.

I will just cover how I did it on webfaction. To check out how to do this on any other hosting provider, you can google ‘301 redirect htaccess <yourhostname>’

On your webfaction control panel, do the following-

  1. Create a new Static/CGI/PHP App – let’s call it dummyapp.
  2. Create a new website mapping to dummyapp. If you were mapping both www and non-www domain to your working app before, you will need to remove the non-www domain from that app first. You should now have something like below where festsy is the working app and dummyfestsy the new app we created only for redirects.
  3. Now, ssh to your webfaction root and go to webapps/dummyapp/ Remove any file that exists there (such as index.html). Now add a .htaccess file with just one line – Redirect 301 / Do NOT forget the trailing slash at the end else your extended urls won’t work. Save and close.
  4. Go to a browser and test It should redirect to Also try an extended url to be safe e.g. in my case. If you set up the trailing slash correctly in previous step, this should redirect to

And, that’s it! I found this to be the easiest way for redirections. Hope it helps.

Leave a Reply

Your email address will not be published.