How to redirect non-www URLs to www?

In order to redirect all of the requests for yourdomain.com to www.yourdomain.com, you should set the appropriate rewrite rule. This can be done by adding the following lines at the beginning of the .htaccess file in your public_html folder:

 

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

From now on, when someone accesses http://yourdomain.com s/he will be redirected to http://www.yourdomain.com.

 

Using this method is safe because it should not create any redirection loops nor it should interfere with other rewrite rules.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Domain Name Propagation

Once you make changes to your domain with the registrar you purchased your domain from, the...

Website Hosting Control Panel

Web World uses CPanel as our preferred hosting control panel. The control panel gives you control...

How to create/remove/edit an email account

Instructions on how to create an email account in your Cpanel Hosting with Web World. Login to...

Powered by WHMCompleteSolution