Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-settings.php on line 472

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-settings.php on line 487

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-settings.php on line 494

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-settings.php on line 530

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-includes/cache.php on line 103

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-includes/theme.php on line 623

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-content/plugins/tantan/tantan_reports.php on line 143

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-content/plugins/tdo-mini-forms/admin/tdomf-form-hacker.php on line 79

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-content/plugins/tdo-mini-forms/admin/tdomf-form-hacker.php on line 118

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-content/plugins/tdo-mini-forms/admin/tdomf-form-hacker.php on line 122

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-content/plugins/tdo-mini-forms/admin/tdomf-form-hacker.php on line 126

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-content/plugins/tdo-mini-forms/admin/tdomf-form-hacker.php on line 130
The How And Why Of 301 Redirects

Monday, April 9th, 2007...7:18 am

The How And Why Of 301 Redirects


Deprecated: Function eregi() is deprecated in /nfs/c02/h06/mnt/46791/domains/thewrongadvices.com/html/wp-content/plugins/tpbc.php on line 96

Why would you want to set up a redirect?

  1. To preserve search engine ranking on a page which has moved.
  2. If your website has moved to a new domain.
  3. To redirect incoming visitors to www.yourdomain.com instead of yourdomain.com, or vice versa.

The last point is the one I want to address in a little more detail, as it can have a significant effect on your PageRank and search engine rankings.

If people are linking to both yourdomain.com and www.yourdomain.com you will be losing the benefit of much of those backlinks because Google will treat each of those URLs as two distinct sites.

This is a bad situation for a number of reasons.

  1. Search engines, and especially Google, don’t like seeing duplicate content, and will punish you for it.
  2. You will have two different pages of content competing for the same spot on search engine results pages.
  3. Your PageRank won’t be as high as it could be if all your backlinks counted towards just one URL.

If you implement a redirect you will have one consistent URL being displayed all the time and the chances of someone linking to the wrong domain will be reduced significantly, and in doing so each of the above points just about become a non-issue.

Whether you redirect to www.mydomain.com or mydomain.com is up to you. There doesn’t appear to be much of a difference between the two as far as search engines are concerned so it will come down to personal preference.

How do you implement a redirect?

The best method, which is also favoured by search engines, is a 301 redirect.

First of all you will need to have a .htaccess file in your root directory. If one doesn’t already exist you will need to create one. The easiest way is by creating a file called htaccess.txt on your computer, copy it to your server and then rename it .htaccess. If you find you can’t see the file on the server you will want to check that your ftp program has the “show hidden files” option turned on.

The other thing to keep in mind is the Apache Mod-Rewrite module needs to be enabled on your server. On some hosts this is enabled by default, on others there may be an option you need to select to enable it, whilst some may disallow it altogether. You will have to check with your host to find out.

Once you have all of that sorted you can start editing the .htaccess file.

If you want your site to be accessed only with the www prefix:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com$ [NC]
RewriteRule .* http://www.mydomain.com/ [L,R=301]

If you want your site to be accessed only without the www prefix:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^mydomain\.com$ [NC]
RewriteRule .* http://mydomain.com/ [L,R=301]

To redirect from an old domain to a new one:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.mynewdomain.com/$1 [R=301,L]

To redirect directories:

Redirect 301 /olddirectory http://www.mydomain.com/newdirectory

To redirect specific files:

Redirect 301 /olddirectory/file.html http://www.mydomain.com/newdirectory/file.html

5 Comments

  • What a coincidence. I was just messing with 301 redirects over the weekend to shore up some broken links to very old deleted content and also fix the problem you talk about of duplicate content. I pulled a bit of hair out, but finally got things working how I want them to ;P

  • I want to make a redirection from the domain root to subfolder…can it be done with this 301 redirects? What other ways are there?

  • It sure can Aki but depending exactly what you want to do there may be an easier way. Send me an email with a little more detail on what you’re trying to do and I’ll give you a hand.

  • A nice Post Dan!
    The problem is huge when you are hosting your blog on Blogger.com! You can’t implement a 301 or 302 redirection and all the blogger blogs are having this very problem.
    I have left blogger for this very reason! and I have also written a post on this topic in my blog!

  • [...] 301 redirects are the preferred method because they are search engine friendly and will pass on link juice. [...]

Leave a Reply

You must be logged in to post a comment.

Blogarama - The Blog Directory Personal Blogs - Blog Top Sites Link With Us - Web Directory