A 301 Redirect Guide for the Clueless!
Ranked #196 in Internet, #7,793 overall
A 301 Redirect Guide for the Clueless!
Whether you want to delete or consolidate web pages, it's always best to pass all of their search engine merit over to another existing page, to salvage visits, page rank and old backlinks. This is what a 301 redirect will do for you!
Contents at a Glance
301 Redirect Scenarios
The 301 redirects being reviewed in this tutorial are strictly for .htaccess file redirects and the Apache web server with the function mod rewrite turned on (this is on by default).
In each example, you'll see a shaded gray line with a command in it. You can simply copy that command and paste it into your htaccess file, under the line "RewriteEngine on" (this is mandatory). If "RewriteEngine on" doesn't exist in your htaccess file, simply type it in yourself.
Single Page 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. Did you notice that the first link only requires you to type out the page, while the second link has the entire URL? This is the proper syntax, and it must be typed this way.
This also works for redirecting pages that have no extension, such as .html or .php - typically the kinds of pages you'll get when you use a content management system like Joomla or Wordpress. Using the above example, let's assume those pages have no ".html" after them. This is how we'd do the 301 redirect:
Redirect 301 /old http://www.mysite.com/new
Note that there is no "/" after the page name in that re-direct...we'll learn why, later!
Non-www to www
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite.com
RewriteRule (.*) http://www.mysite.com/$1 [R=301,L]
In doing so, you're eliminating search engine issues that arise from having "two versions" of a website, which also taint analytics results.
Rename A Folder
redirect 301 /newcars/ http://www.mysite.com/cars/
You can perform this redirect for deeper level folders, too. So, say you want the folder "mysite.com/cars/classic/" to move over to "/cars/all/classic/." You'd use this:
redirect 301 /cars/classic/ http://www.mysite.com/cars/all/classic/
Unlike previous examples in this tutorial which involved redirecting from one page to another, please note that you'll have to leave the "/" after folder names in a folder-to-folder redirect. That's because the trailing forwardslash denotes a "folder."
For example, this is a page: "mysite.com/test" and this is a folder: "mysite.com/test/"
Move A Folder
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, such as "mysite.com/cars" and all of its individual pages over to the single page "mysite.com/things/stuff.html"
redirectMatch 301 ^/cars/ http://www.mysite.com/things/stuff.html
Domain to Domain
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.new-domain.com/$1 [R=301,L]
There are two important things to note about this. For starters, this is somewhat of a "lazy" way to move a website. You're not moving the individual folders or pages over to their new counterparts on a new website; instead, you're just moving everything over to the home page of the new site. The alternative is to write a 301 redirect command for every single folder or page, if you really need to retain each page's search engine ranking.
Secondly, when you 301 redirect an old domain to a new one, be aware that you'll have to keep paying for the annual domain renewal and server account of the old domain name. Make it a point to change all of the backlinks that were pointing to the old domain, so that they point over to the new one. Once all backlinks are changed, you can consider dropping the old domain (unless it's a good domain that gets decent type-in traffic).
Example .htaccess

Additional 301 Info
301 Redirect Statements
- [NC]: The statement [NC] can be used within a 301 redirect rewrite rule. It simply tells your server that the value before it is not case sensitive, and ignores differences between capitalized and non-capitalized letters.
- [L]: This statement, when used at the end of a rewrite rule, tells the server that it is the "last line" in the set. Anything that comes afterward will not be processed in that set. For instance, "RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]"
- Options +FollowSymLinks: You might see this in your existing htaccess file, before "RewriteEngine on". It's a statement that enables your "Mod Rewrite" function.
Verify that the 301 Redirect Worked!
301 Redirect Tips, Tricks and Info
- 301 redirects are instant, because the .htaccess file is read before the page loads.
- You won't need to do a 301 redirect to any pages that have no backlinks, technically...well, unless they have good search engine rankings. Otherwise, simply delete or rename the desired pages and re-submit an XML sitemap using Google Webmaster & Bing Webmaster.
- 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) - making them a vital part of an SEO roadmap for a changing site. The passing of page rank from a 301 redirected page to another page will not be instantaneous.
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.
Comments & Feedback
-
Reply
-
upstarter
Sep 21, 2011 @ 7:11 pm | delete
- If I want to migrate to new domain, do I have then to 301 redirect the whole site (every link individually)?
-
-
Reply
-
altamiraweb
Nov 17, 2011 @ 5:01 pm | delete
- How can I redirect the inner pages of a domain to the homepage?
Mi site is Posicionamiento web en Google
-
-
Reply
-
Pixelrage
Jan 10, 2012 @ 11:49 am | delete
- Follow the "single page redirect" above, but point it to www.yoursite.com. If there are too many pages and if this would take too long, then re-direct all of the folders to www.yoursite.com.
-
-
Reply
-
Pixelrage
Jan 10, 2012 @ 11:47 am | delete
- It depends on if you want those individual pages to maintain their SE rankings. If the pages are high up in search engines, it is worth your while to 301 redirect every page individually. Otherwise, just redirect the folders and re-submit an XML sitemap.
-
-
Reply
-
RebelPhoenix
Sep 2, 2011 @ 7:56 am | delete
- Great, all important info in one place, thanks!
-
- Load More
by Pixelrage
A quick 301 redirect tutorial
- 215 featured lenses
- Winner of 17 trophies!
- Top lens » The Best HDTVs for 2012