Latest tutorial: Premium Flash Files | Ask Tutorial5! | Subscribe to RSS Register Login Find Hobbies
Advertisement

Get tutorials on EMail




Do you need more help? You can now Ask Tutorial5! and get free support - Ask a question now!

How to 301 Redirect Non-WWW to WWW URLs

(1 vote)
Software - Search engine optimization
Written by DanielH   
seo logoOne of the first things you should consider when starting any SEO work on a website is deciding if you are going to use the www.example.com or example.com base URL.
Many search engines consider those two URLs different, other sites that link to yours could also use different versions of your URL and that mix can really hurt on the long run.

Using a 301 permanent redirect to the www version of your website will secure and consolidate your base domain and all the inbound links.

Redirect Non-WWW to WWW on Linux hosting

The simplest way of achieving this is by altering the .htaccess file in your websites root directory.

Download the .htaccess file to your computer using your favorite FTP client, open and edit it.

If you do not have a .htaccess file you can create one and upload it, look harder tough, these files are usually hidden.

If your website root directory does have a .htaccess file open it and first check to see if the rewrite engine declaration is posted: RewriteEngine On

If the Rewrite Engine is On then go ahead and add this following code to your .htaccess file:
Remember to backup your .htaccess file before you start editing it.

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


Remember to replace example.com with your websites URL.
Upload the .htaccess file to your website, replacing the old one, and then try accessing your website without the www. If you are not automatically redirected to the www version then check your spelling and follow this tutorial from the beginning.



Subscribe now via RSS feed and get all the new tutorials


Do you need more help? Ask now!
 

busy
Last Updated ( Friday, 11 January 2008 )