301 redirect tutorial (Apache Server)

301 redirect tutorial (Apache Server)

By Luke on September 5, 2009

301 redirect tutorial (Apache Server)

What is a 301 Redirect and how do I use it?

We recently added an SEO Glossary definition for canonicalisation (canonicalization), and the most common form of canonicalisation is domain duplication. For example, non www and www versions of a page have been cached by a search engine:

i.e. domain.com and www.domain.com are both cached.

In order to counter this issue, you can set up a 301 redirect. A 301 redirect is a permanent redirect and will tell the search engines that a page has permanently moved from the old address to the new address. So how do you set this up? Well, if you’re on an Apache server (arguably the better server for SEO) which is non-Microsoft and supports PHP and MySQL i.e. for WordPress then you need to create what’s called an .htaccess file. Some hosting companies won’t give you access to this, but if they do, use notepad or a similar text editor to add the following code:

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

Within the code, replace “domain.com” with the domain name of your site. What the code does, is redirect any non www page to it’s www page equivalent. To test it out, if you try to access seo-creative.co.uk, you will automatically be re-directed to www.seo-creative.co.uk.

Canonicalisation problem solved! If you have any questions about canonicalisation or other internal content duplication issues on your site, feel free to contact us or leave a comment on this blog post. Enjoy!

Falkon blog post featured image for post - WordPress Templates

WordPress Templates

Ever wanted to customise a single page in WordPress with the template system but never knew how? Its simple with...