Simple SEO Tips for Web Designers and Developers: The 301 Redirect

John Reeve | May 12th, 2011 | , , ,

301 Redirects: Simple SEO Tips for Web Designers and DevelopersIt seems like there is a lot of voodoo that goes on in the SEO world, but the truth is most SEO practices are quite practical and applicable to web sites and web-based applications. One such practice is the usage of 301 redirects. The 301 status code is used to tell web browsers and search engines that the requested content has moved permanently:

The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible. This response is cacheable unless indicated otherwise.

Issuing a 301 status code along with a redirect returns a new URL in a Location header that basically tells the web browser, or search engine, to disregard the requested URL in favor of the one returned. There are two reasons why this can be very useful for web designers and developers who are launching new web sites and/or maintaining existing web sites.

Keeping a Web site under one domain

Most of us are used to typing out a full domain name, including the subdomain for the web server, when going to a web site. For example, we’ll enter www.google.com into the web browser location bar. But what happens when we enter just google.com? In this example, Google returns a 301 status code, informing the web browser to do a redirect to www.google.com. However, most web sites won’t do this by default. This is especially true of web sites running on the Apache web server, where a non-WWW URL is considered the same as a WWW URL.

In this case, it is necessary to redirect the non-WWW URL to the WWW URL. If not, Google and other search engines will see your web site as two different web sites with the same exact content and will likely lower your page rank as a result. If you are running a web site on Apache, and you have mod_rewrite installed (mod_rewrite is usually installed by default), the fix is as simple as adding the following lines of code to the .htaccess file in the document root folder of the domain:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [L,R=301]

This R=301 code is instructing the Apache web server that if the domain does not have any subdomain, to return a 301 status code and and instructions to redirect to the full domain of the web site in the Location header. The L code tells Apache to stop processing any more rules after this one.

Maintaining Web site archives

One of the most exciting projects for a web designer or developer is a web site redesign. These projects are ideal because the client is handing us a clean slate and asking us to rework their web site from the ground up. We get to decide how the site will be designed, how the content will be displayed, and what technology will be used to serve up the web site.

But we also have to remember that the web site had a history before we completely eradicate any traces of the old web site. The site we are redesigning was indexed by several search engines that include a site’s age in the algorithms it uses to calculate page rank. If we simply replace the old web site with the new one, we are throwing out all of that history, and that will have a large negative impact on the new web sites ranking.

By using 301 redirects, we can preserve the history of the old web site and guide search engines and web browsers to the new content. The first thing to do is to take inventory of the pages that have been spidered by search engines. To do this in Google, search for site:example.com. Then decide which pages need to be mapped to new ones and implement some 301 redirects to handle them. Again, using Apache as the example, the rewrite rules in the .htaccess file would look something like this:
RewriteRule ^old-web-page.html$ /new-web-page.html [L,NC,R=301]

Adding this 301 redirect to maintain archived web site content becomes increasingly important. In an age of trackbacks, tweets and facebook likes, all of it being archived and searchable, you want people to be able to get to your site and its contents without having to face off with the dreaded 404 page.

Photo credit: spacepleb

Leave a Reply

Intervals Blog

A collection of useful tips, tales and opinions based on decades of collective experience designing and developing web sites and web-based applications.

What is Intervals?

Intervals is online time, task and project management software built by and for web designers, developers and creatives.
Learn more…

John Reeve
Author Profile
John Reeve

John is a co-founder, web designer and developer at Pelago. His blog posts are inspired by everyday encounters with designers, developers, creatives and small businesses in general. John is an avid reader and road cyclist.
» More about John
» Read posts by John

Jennifer Payne
Author Profile
Jennifer Payne

Jennifer is the Director of Quality and Efficiency at Pelago. Her blog posts are based largely on her experience working with teams to improve harmony and productivity. Jennifer is a cat person.
» More about Jennifer
» Read posts by Jennifer

Braden Jones
Author Profile
Braden Jones

Braden is a co-founder and strategist at Pelago. His blog posts draw from his worldwide business travels and forays into the retail apparel industry. Braden loves to surf and recently adopted a Doka named Moose.
» More about Braden
» Read posts by Braden

Michael Payne
Author Profile
Michael Payne

Michael is a co-founder and product architect at Pelago. His contributions stem from experiences managing the development process behind web sites and web-based applications such as Intervals. Michael drives a 1990 Volkswagen Carat with a rebuilt 2.4 liter engine from GoWesty.
» More about Michael
» Read posts by Michael

help.myintervals.com
Videos, tips & tricks