Redirect Non www to www URL

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 

non www to www 03When we build websites to serve our users, our aim is simple that is to keep the site simple. Now most often our users type the address of the website sometimes with www. and sometimes without www.

Now, why in the world would someone not type www and try visit a website. Well, you cannot blame users for that and look up for a solution to keep our users who come in to the site without typing in the www prefix with the URL. 

Our focus should always be around the users and keep the site navigation friendly. Asking our users of forcing hem to enter prefix with our site is not a solution, since not every user is going to follow the guideline. Instead we will have a solution implemented to handle the users who do not prefix www.

There are loads of articles that talk about how to achieve a successful redirection of non-www URL to www URL. I have seen too many complicated steps involved in to implement a simple solution.

 

Procedure 01:

  1. Go to the public_html folder [root of the site] of your hosting
  2. Locate htaccess.txt and rename it to .htaccess
  3. Now open it and
    1. Remove hash symbol # from "RewriteEngine On" to turn the rewriting engine on
    2. Add the following code to redirect non-www URL to www URL Ex: URL http://myblogginghelp.com will be redirected to http://www.myblogginghelp.com

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

 

Procedure 02:

Here is a quick way to achieve it:

  1. Go to the public_html folder [root of the site] of your hosting 
    • if multiple domains are hosted on the same hosting plan, go to the root folder of the domain you are willing to redirect.
  2. Locate .htaccess file, if you do not find it look for htaccess.txt. If both are not found create a new file with a name .htaccess
  3. Now open this file and add the following code under this file 
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

 Did you Find it helpful?, drop a line and share it forward to help others. Have a nice day.

About the Author
Syed Hussaini
Author: Syed HussainiEmail: This email address is being protected from spambots. You need JavaScript enabled to view it.
Brief Bio
A business consultant with 13+ Years of extensive expertise in IT Services Management (ITSM), Incident, Problem & Change Management. Additionally, I hold great knowledge of Web development, eLearning Solutions, Web Analytics and CMS Tools.

Get in Touch

Contact me for work opportunities

Follow Me

facebook color   google plus color linkedin color youtube color twitter color