Search:

SEO Blog – Search Engine Optimization Blog

Better My Chances For Good SERPs

About Us

SEO Blog - Search engine optimization.
Tips and tricks for improving your websites position in search engines.
Helpful information for beginners to experts to get better SERP's

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

bettermychance.org

or

www.bettermychance.org

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: , , , , ,


  1. No comments yet.

Leave a Reply

You must be logged in to post a comment.