Loading...

Knowledge Base

Redirect to www.yourdomain.com

There is much discussion about whether it’s best for your site to display ‘yourdomain.com’ or ‘www.yourdomain.com’. While it technically doesn’t make a difference some people have their own preference for varying reasons, such as potential SEO benefits or the need for having a consistent domain address.

It’s super easy to push all requests for 'yourdomain.com' to re-direct to 'www.yourdomain.com'! To begin implementing this re-direct you’ll need to make an .htaccess file. 
 

If you already HAVE an .htaccess file in the public_html folder of your cPanel account, then simply add the text below to the top of the file and save it:

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


If you DO NOT already have an .htaccess file in the public_html folder then you’ll just need to create one:

  1. Open your favorite text editor (notepad, textedit)

  2. Save the file as .htaccess (yes, that ‘.’ at the beginning is supposed to be there)

Once the file has been created add the code shown below to the file and save it again:

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

 

Now, all that’s left to do is upload this file via either FTP or cPanel File Manager, and make sure that it’s in the public_html folder of your cPanel account. To verify your changes go ahead and visit your website (without the ‘www.’) and it should automatically change ‘yourdomain.com’ to ‘www.yourdomain.com’.


Note: if you recently visited your site before making the change then you may need to refresh the page or clear your web browser’s cache to see the changes.

Did you find this article helpful?

 
* Your feedback is too short

Loading...