301 Redirects

Want to grow your organic traffic by 20-100%? We built ClickFlow, a suite of SEO tools designed to increase your organic rankings and scale qualified traffic for your website. Click here to learn more and get started.

A 301 redirect is used when you need to tell the search engines (Google, Yahoo, MSN etc) that your website or web-page has moved permanently. This allows the engines to update their indexes with the new information. Assuming you don't deactivate the old domain (if you are doing a domain change) then theoretically Google will pass all your backlink and PR info to the new URL once the 301 redirect has been established and recognized. This should help maintain the integrity of whatever value and rank the old domain had established.

Most useful 301 redirects for Search Engine Optimization (SEO)

* 301 redirect an entire site (for example change of filename(s) or new domain name)

* 301 page-to-page redirect (for example change of filename(s) or new domain name; most commonly used in search engine optimization when many pages are indexing and ranking and you want to carryover PR [PageRank] to each individual page)

* Resolving canonical issues with a 301 mod_rewrite (this involves making sure your non-www domain resolves to your www.yourdomain.com domain. If you do not have this in place the engine may recognize your domain as being two separate domains which in turn could cause duplicate content issues or allow your Page Rank to be split between the two domains. When using a 301 mod_rewrite, the engine will be able to recognize that yourdomain.com and www.yourdomain.com are the same entity.

301 Redirect Scripts:

* htaccess
* 301 mod_rewrite
* PHP
* ASP
* ASP .NET
* CGI/Perl
* Ruby on Rails
* IIS
* Java (jsp)
* Coldfusion

Note:
Avoid using meta-tag refreshes and javascript re-directs. Due to abuse by some webmasters and deceptive SEO practices utilizing these methods these are deemed poorer choices and may not provide you with the desired result. You are better off implementing a 301 redirect and will have to deal with less hassles and possible complications from the search engines. Do yourself a favor and use a 301 redirect as advised by all the major search engines. (.htaccess and the 301 mod_rewrite should resolve most issues) Other scripting options have been provided for your convenience.

.htaccess 301 Redirect

You can save yourself some time by implementing your 301 redirects through the htaccess file. Instead of creating redirects on each webpage, you can just add the code to the htaccess file.
To implement a 301 redirect using htaccess:

1.Create a file on the root directory of your website, name it “.htaccess”.

2.Open the .htaccess file using notepad or what ever text editor that you prefer.

3.Add the following into the .htaccess file, save it and then upload it to your web server:

Redirect 301 /old/old.html
to http://www.yourdomain.com/new.html
NOTE:
Do not add “http://www” to the first part of the statement – place the path from the top level of your site to the page. Also ensure that you leave a single space between these elements:
redirect 301 (this is the instruction that the page has moved to a permanent new location)
/old/old.html (this represents the original folder path and file name)
http://www.yourdomain.com/new.html (this represents the new path and file name)
Also note that you can redirect the page to another domain, an equally useful purpose for using the 301 redirect, is redirecting old pages to the new pages on the same domain; it all works the same way!

301 Redirect Using Mod_Rewrite

As stated earlier this will resolve the issue of your non-www domain and your www domain. What does that mean? When we build sites we often use www.yourdomain.com. However, many webmasters when linking to a site may want to save time and simply link to the site by using yourdomain.com. In Google’s eyes these may be viewed as separate sites. So you may have a total of 100 hundred backlinks with 60 pointing at yourdomain.com and 40 pointing at www.yourdomain.com. Or you may be viewed as having duplicate content. Ideally, you want all backlinks pointing to one version of the domain to address these issues.

By inserting the code below into your .htaccess file, it will solve the problem by redirecting anything linking to yourdomain.com to www.yourdomain.com, and this allows you to pass on the PageRank [PR] from one version to the other.

RewriteEngine On rewritecond %{http_host} ^yourdomain.com
rewriteRule ^(.*) http://www.yourdomain.com/$1 [R=301,L]

PHP 301 Redirect

Add following code to page or script:

header( “HTTP/1.1 301 Moved Permanently” );
header( “Status: 301 Moved Permanently” );
header( “Location: http://www.new-url.com/” );
exit(0); // This is Optional but suggested, to avoid any accidental output
?>

ASP 301 Redirect

Add following code to page or script:

<%@ Language=VBScript %>
<%
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”, “http://www.new-url.com/”
%>

ASP .NET 301 Redirect

Add following code to page or script:

CGI/Perl 301 Redirect

Simply add this code to your cgi/perl script:

$q = new CGI;
print $q->redirect(” http://www.new-url.com/ “);

Ruby on Rails 301 Redirect

Simply add this code to your ruby/ruby on rails script:

def old_action
headers[“Status”] = “301 Moved Permanently”
redirect_to “http://www.newpageorsite.com/”
end

IIS 301 Redirect

1.In internet services manager, right click on the file or folder you wish to redirect.
2.Select the radio titled “a redirection to a URL”.
3.Enter the page that the page will be redirected to.
4.Check “The exact url entered above” and the “A permanent redirection for this resource”.
5.Click on ‘Apply'.

Once you have implemented the necessary changes. Test it. You should be able to enter your old URL and be seamlessly be redirected to the new URL. When moving many files (1000s) you may want to do it in small batches to make sure everything is propagating properly.

The 301 redirect is the safest way to preserve your rankings. The next time Googlebot, MSN, or Yahoo visit they will recognize that your webpage or entire site has permanently moved and they will make sure to update their index. As the indexes update your old URLs should drop out and the new ones will be presented. Even if your old ones are still displaying they will direct properly to the new domain. It is not necessary, but advisable to let others know (i.e. old link partners, directories, etc) that you have changed your address so they can make appropriate changes to your URL if they chose to. This is also an opportune time to review the anchor text linking to your site and have the necessary changes implemented as well. Good Luck in your endeavors.

With offices based in Orange County and Los Angeles, Single Grain search engine optimization specialists are available for SEO, Search Engine Marketing (SEM) and Social Media Marketing (SMM) consultation.

Avatar
Write for us

Think you’ve got a fresh perspective that will challenge our readers to become better marketers? We’re always looking for authors who can deliver quality articles and blog posts. Thousands of your peers will read your work, and you will level up in the process.

Contribute to our blog