A 301 Redirect Guide for the Clueless!
I wrote this guide because I never seemed to find the answers I was looking for on other 301 redirect tutorials. This one basically covers all of your bases, and would require you to otherwise have visited several tutorial sites :)
Why Use A 301 Redirect?
301 redirects are helpful because they're search engine friendly and the ultimate way to pass on credit from an old page to a new one. Even if you're looking to delete a page - use a 301 redirect to forward it to your home page, or the parent page it was under, so that any old hyperlinks out there won't point to a 404 - Not Found page. Don't worry about redirections - once you've added the 301 redirect statement, search engines will do the rest!
About This Tutorial
You'll see 301 Redirect code snippets in this tutorial - you can simply copy and paste them into your .htaccess file, and edit "mysite.com" with your site name.
301 Redirects: Table of Contents
Find your redirect scenario below!
Apache Users: Make Sure MOD REWRITE is On!
LoadModule rewrite_module modules/mod_rewrite.so
This is basically a default step, but definitely something worth mentioning in case everything seems to "look" right, but still doesn't work, after implementing your 301 redirect.
Urgent: The RewriteEngine Line
RewriteEngine ON
You'll want to put all of your 301 redirect statments UNDER this statement. If this statement doesn't exist, simply type it in as the first line. Note that if RewriteEngine ON doesn't exist in your .htaccess file, then 301 redirects simply will not work! With that being said, let's assume that you'll be using any of the 301 redirect tutorials below by inputting them below the "RewriteEngine ON" line, rather than me stating it under every single tutorial.
A Single "Page A to Page B" 301 Redirect
Redirect 301 /old.html http://www.mysite.com/new.html
The first URL is the one being directed, and the second URL is the one it is being redirected to. Note how you must not type out the full web address for the first URL!
Note: You only have to include the line "RewriteEngine ON" only once in your .htaccess file...therefore, I won't keep repeating it in all of the examples below.
301 Redirect a non-www Domain to a www Domain
RewriteCond %{HTTP_HOST} ^mysite.com
RewriteRule (.*) http://www.mysite.com/$1 [R=301,L]
(...of course, replacing "mysite.com" with your actual site name)
301 Redirect a Folder to a New Location, But Leave its Contents In-Tact
redirect 301 /cars/ http://www.mysite.com/newcars/
If you have a 2nd, 3rd, 4th, etc. level folder, like http://www.mysite.com/cars/classic and want to move "/cars/classic" over to "/cars/all/classic": http://www.mysite.com/cars/all/classic, you'd use this:
redirect 301 /cars/classic/ http://www.mysite.com/cars/all/classic/
* Note that when you redirect folders, always leave the trailing "/" after the folder names.
301 Redirect an Entire Folder & All of its Contents
redirectMatch 301 ^/cars/ http://www.mysite.com/products/
Similarly, say that you want to redirect an entire folder and all of its contents to a single HTML page (or whatever other page, like PHP, ASPX, etc.). For example, I want to move the entire category http://www.mysite.com/cars and all of its individual pages over to the single page, http://www.mysite.com/things/stuff.html:
redirectMatch 301 ^/cars/ http://www.mysite.com/things/stuff.html
Premanently redirect a domain to a another domain
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.new-domain.com/$1 [R=301,L]
Note that when you 301 redirect an old domain to a new one, you'll have to keep paying for the annual domain renewal and server account of the old domain name. It's a real pain - but once the 301 registers and all traces of backlinks to the old URL are nowhere to be seen, you can consider removing the old domain and its account. Do not remove the account if the old domain still gets direct type-in traffic, though.
The [NC] statement
Beware of [L]
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]
Notice the "L" in the brackets, near the end? Note that the "L" represents "last line". So, anything after this statement will not be processed if this line matches. In other words, if you have two conflicting rules running at once, you'll want to use "L" at the end of the one that takes precedence (thanks to user Rhinoooow for this info!)
Verify that the 301 Redirect Worked!
To see which redirects were unsuccessful, you can use a free 301 redirect checker. Please note that you MUST do this if you have re-directed your non-www URL to your www URL, otherwise, pending issues may exist that you are not aware of.
301 Redirect Tips, Tricks and Info
- 301 redirects are instant, because the .htaccess file is consulted before the page loads.
- You won't need to do a 301 redirect to any pages that have no backlinks or type-in traffic. Simply rename the pages, and re-submit an XML sitemap to your Google Webmaster and Yahoo Explorer accounts.
- When you've done a 301 redirect, check all pages involved: if you've redirected a main page, check both that page and several of its sub-pages to make sure they are behaving the way you've anticipated.
- 301 redirects pass all page rank and SERPs (Search Engine Results Pages rankings). The passing of page rank from a 301'ed page to another may take approximately a month or two to display properly (or as long as one "Google PR update cycle").
More 301 Tips & Resources
- Redirects - groups.google.com
- A Google representative writes an insightful article about redirects and misconceptions.
- Best Practices When Moving Your Site (Google Webmaster Blog)
- What to do when you have a major 301 redirect task or a complete site move. Includes a checklist of everything that should be done for best results.
301 Redirect Tutorial: Reader Feedback
![]()
Thanks for visiting my tutorial - leave a comment if you'd like :)
-
Reply
- Pixelrage Pixelrage Sep 25, 2009 @ 10:50 am | in reply to Rhinoooow
- Thanks for the info! I've corrected it.
-
Reply
- Rhinoooow Rhinoooow Sep 22, 2009 @ 7:24 pm
- Very good, but you've incorrect with the warning about L. It only stops processing other rules if this one matches.
Sometimes its ESSENTIAL - e.g. a CMS system that rewrites pages but you have rule to 301 an old page to a new one - you don't want both rules running at the same time.
http://www.addedbytes.com/apache/mod_rewrite-cheat-sheet/
-
Reply
- GoldLizard GoldLizard Jun 8, 2009 @ 1:12 pm
- THANKS for this thorough guide! I've bookmarked this page and I'm rating it 5 stars.
-
Reply
- logiclabz logiclabz Mar 25, 2009 @ 11:33 pm
- Being a SEO beginner learnt
to redirect. Good and clean post
We can use the URL Redirect Checker to check any status code like 301, 404, 302 etc.
-
Reply
- CarolSue CarolSue Nov 16, 2008 @ 7:29 pm
- a great lens with useful information! had a problem with my redirects and he was kind enough to email me personally and help. A plus to have this type of member in our squidoo community!
- Load More




