301 Redirect - 301 Redirect Non WWW URL To WWW URL
An important factor to remember when first setting up your site is to decide how you would like your URL’s to be displayed. you should choose one and then stick to it.
For example, do you want your name to be displayed as
or
Personally i prefer the more traditional method including the www. at the front of the URL.
So what do i need to do once i have decided the format i want my URL to be displayed in?
The following bit of code needs to be placed in your sites root directory in a file called .htaccess
If you don’t have one, create one via ftp.
If you have decided to go for the www version you need to use the following code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.co\.uk
RewriteRule (.*) http://www.example.co.uk/$1 [R=301,L]
Remember to change example for your own domain.
If you want to use the non www version use this code
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
Again remember to change the example for your own domain.
This is designed to work on Linux servers and will not work on windows server based hosting
Tags: 301 redirect, htaccess, mod rewrite, non www, seo, www
01.Oct.07
SEO Basics
Comments (0)