You may have heard the term 301 redirect and wondered what it is or what it’s used for. You may even have wondered why you would want to use it one or how to apply it to your site. One of the most common reasons to use 301 redirects is to help improve the seo of your site.
A 301 redirect is an example of an http status code. http status codes are sent from the server to your browser when you request a web page. Some of the more common status codes are 200 OK which is what you’ll usually get for most pages you view. Another common status code is 404 Not Found when you request a page that doesn’t exist. The 301 status code stands for Moved Permanently and is a way to tell the browser and search engine that the requested url has been assigned to a new url and all future references to this url should go to the new url instead, thus the permanence.
Huh? Canonical urls? What’s the? It’s basically just a fancy way of saying more than one url can point to the same web page. You may for instance own two domains for your site yourdomain.com and your-domain.com. Even if you have only one domain your web host has probably set things up so people can find your site with and without the www in front. While it might seem like yourdomain.com and www.yourdomain.com are the same domain they are actually seen as two different URLs. Search engines won’t necessarily know which one is really your main url unless you tell them.
Having more than one URL pointing to the same web page can cause your seo efforts to be divided by what search engines see as separate pages. For example say on one site you have a link pointing back to your site with the www and another site the link points back without the www. Search engines will see those links pointing to different URLs so instead of actually having two backlinks you’ll have one on one site and one on another site effectively dividing your backlinks in half. Now why go to all that work for half the results. It’s true you have a measure of control when you add the link to that other site, but there will be many times when you don’t and there’s no way for you to know which of the two versions of your domain is being used in the link.
The situation can get worse if you use relative links in the navigation of your site. When someone comes to your site with the www every time they click a link within your site the URL will use the www as well. When the come to the site without the www none of the urls of your relative links will use it either. This is also true when search engine spiders visit the site. Spiders will visit your site with both URLs and see all your pages as one of the other each time they visit. You’d rather them realize they’re on the same site don’t you.
You can read more about canonical issues with urls at Matt Cutts blog and his post SEO advice: url canonicalization.
301 Redirects To The Rescue
To prevent your seo linking efforts from being diluted you can use 301 redirects to let search engines know that the two versions of your URL are one and the same. Once you’ve set up 301 redirects for your various URLs it won’t make a difference which one will be used in the link since they will all be pointing to the same URL. It doesn’t really matter whether you want to have the non www URL pointing to the www URL or the way around. Just pick one and set up the redirect. Most people tend to point things to the www version, but it really doesn’t matter.
You can also set up 301 redirects to point from obviously different URLs like yourdomain.com and your-domain.com. Again just make sure all your urls all point to the one URL. Your 301’s don’t have to be limited to different versions of your main URL either. It’s quite possible you’ll remove a page on your site or rename it to something else. Why give up any link benefit pointing to those pages. Redirect the old page name to the new one on your site or those now non-existent pages to the closest related page and you still profit from any links out there. Anyone who happens to click on an outdated link pointing to the old url will also appreciate being taken to your new page instead of getting the message that the page they wanted couldn’t be found.
Setting Up 301 Redirects
Now that you’re convinced you should use them you’d probably like to know how to set them up. There are a variety of ways and often it’s as simple as going through the control panel that came with your hosting account. You can also use php to code the redirect into your directly into your pages. If your server is running apache the way to go is to use mod_rewrite. SEOmoz has an excellent Guide To Applying 301 Redirects in Apache so instead of repeating the information I’ll just send you there. But stick around here till the end first if you don’t mind. The SEOmoz page has code for many of the typical ways you’ll want to redirect one url to another. Still if you want to know more you can look at the Mod_Rewrite Forums for a lot more information or to ask a question.
Of course not everyone uses Apache or php. So for all of you using Microsoft IIS or coding with asp I found this page at wwwcode. Quite honestly I don’t know a lot about IIS servers or asp, but this page seemed to cover what you need to know
To check that you’ve set everything up correctly you’ll want to view the headers for your page. Type your non-www URL and watch the headers that are returned. You should see 301 Moved Permanently on the very first line of the headers returned. If you don’t have a way to check headers or don’t know how you can type your URL into the HTTP Status Codes Checker at seonconsultants. if you use Firefox there are several extensions available you can get that will allow you to view your headers as well.
Search Engine Friendly URLs With Mod_Rewrite
Beyond canonical url issues (you know what those are now right?) there are other ways to make use of redirects with mod_rewrite to create seo friendly urls. You may have a blog or another content management system that use variables in URLs like pid=3. You can use mod_rewrite to change those unfriendly variables to something that includes your keywords. The benefits may not be huge when it comes to seo, but why not take advantage of anything you can. Where it will become useful is for your visitors who will generally prefer to see 301-redirects-for-improved-seo than pid=29. Your more savy visitors will probably even be able to find other pages on your site by guessing at some other titles to your pages or articles that are being reflected in your seo friendly url.
If you use WordPress you don’t even need to know how to use mod-rewrite. WordPress has something called permalinks built in that you can access through the admin interface that will set up all the rewrites for you. Many other blogs and applications that produce dynamic pages will also be able to rewrite your URLs as well. You can always do it on your own by creating your own mod-rewrite code. You need to add your mod-rewrite code to a special file for apache called .htaccess. There’s no extension to the file. It needs to be a text only file so no using Word or any other word processing program. Use Notepad instead. You can take a look at this .htaccess Tutorial for more information.
301 Redirects can help improve the seo you do for your site by not diluting your link building among a variety of different URLs. They will also help retain link benefits to pages you rename or remove entirely from your site. 301 redirects are one of the first things I’ll set up when optimizing any site and they are the only safe way to redirect pages on your site when it comes to search engines. You can also use them to create search engine friendly URLs on your blog, cms, or any other dynamic pages on your site. Whatever else you do to optimize your website and web pages use 301 redirects for improved seo.
Download a free sample from my book, Design Fundamentals.
Wow Steve. You really put a lot of time and effort in your article / blog posts.
Another great post! 🙂
Thanks Tim. I try. They generally seem to take about 2 hours each to write though some have come a little faster and some a little slower. I’ve been trying to collect information from a variety of sources all the time so I have plenty to pick and choose from when I site down to write. And when I do I usually have quite a few resources in front of me already.
And then when I need to I just hop on over to Google and look a few things up. It’s funny because when I first concieved of this blog I was looking to spend about a half an hour wirting each post. I’ve found the only way I can do that is to just write about me and I’m not sure how interesting that would be for anyone.
I’ve been thinking though about trying to get in some quicker posts in between the longer ones on the days I haven’t been writing.