Permanent 301 redirection of non www domains to www domains

How to redirect your domain to domain with www prefixed

redirection of your domain ( name to is very useful and must be done. Reason for this is that when you have a non redirected domain name then search engines will see and as two separate websites. Hence you will lose much of the website traffic due to this.

One of the simplest solution for this is to add a .htaccess file and permanently redirect your domain name to www prefiixed domain name. Here’s how to do it step by step:

  1. Create a file with name ‘.htacess’
  2. Add the following code to it:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^$ [NC]
    RewriteRule ^(.*)$$1 [L,R=301]
  3. replace the ‘’ with your domain name
  4. upload this file to your web servers root folder

Thats it. You are done. You can check the redirection by typing your domain name in the browser without www prefix.

Note: Above told method only works for apache web servers. For IIS servers I recommend reading

Hope this tip will help you! cheers!

Published by

Neeraj Kumar

#technologist #musician #traveller