Website Redirects

Peter Tell
Peter Tellposted on on November 30, 2015

You're ready to launch a new site

Here’s the situation: You’ve been working for months with a development team on the launch of a new company site. You’ve gathered images, written copy, toiled over sitemaps, learned the CMS, and now it’s the day. You wait “patiently” for the word from the development team. Everytime the phone rings you jump a little.

Finally… “Call for you on two.” Tentatively, almost pensively, you click the refresh button. A wave of relief washes over as the new site flickers into focus. Clicking through the pages yields the expected results. Defenses dulled, a smile creeps across your face. You glance over your shoulder to see who’s around. The boss! Perfect timing. “Site’s live.” you say coyly.

“No kidding, that’s great!” She sits next to you and flips open her laptop. Google pops up and you watch as she types in the company name. Your brow furrows just a touch. You’ve always gone directly to the site… what’s this wrinkle? The boss clicks the first link that comes up. It’s the contact us page… the old contact us page. Her head tilts as a confused expression emerges. “Is this right?”. She turns her screen towards you.

And there it is in all it’s glory… the dreaded ‘page not found’ message. If this has ever happened to you, don’t worry, you’re in good company. It’s one of the most overlooked tasks of a site launch: The Redirects.

Redirects

But what exactly are redirects? They are a way of pointing users and search engines to new pages that are analogous to old ones. Search engines have many ways of keeping their indexes up to date. Some sites update daily, but others only get that treatment ever so often. If your site doesn’t get updated regularly, you probably fall into the latter category.

A redirect serves two main purposes. The first is that it makes sure your users get to the correct pages they are looking for. This could be through search engine results, old links, or even old bookmarks. The second is that it’s an alert for the search engines to update their index. The redirects are like a “change of address” you fill out with the Post Office. It cues the system to go, “Oh ok, this page that served this purpose is now over here, sweet. Beep boop bop boop.” (This is actually the noise they make. Trust me, I’m a scientist. (I’m not a scientist))

“Ok”, you’re saying “I get that I need to do it… how?”.

There’s some coding involved, but don’t get discouraged. It’s not too difficult. Some hosting companies even have a task built right into their control panels.

The first thing you want to do is Google the current site and find out which pages are in the index. You can do this by typing in: “site:your-site.com” into the search bar. Try it out with Pageworks: “site:page.works”.

The next step is to go through these pages and figure out what the analogues are for your new site. Maybe the old “Contact Us” form was:

http://my-site.com/contact_us.php

And the new is:

http://my-site.com/contact-us/

The easiest way to do this is just to make a spreadsheet with two columns: Old and New. After you’ve compiled the list, the next step is to make a redirect. There are many different ways to do this but I’ll cover two.

If you’re using an Apache web server that allows decentralized management through an .htaccess file that’s one of the easiest ways to do it. The .htaccess file is most likely in the root of your web directory. If it’s not, check with your hosting provider to see if they allow this sort of configuration. If they do, simply create the file. The line(s) of code you want is the following:

Redirect 301 /old/location /new/location

So, for our example above:

Redirect 301 /contact-us.php /contact-us/

That’s it! You’d simply create a new a line for each path that you want redirected.

Now, this can get a little more technical. Sometimes you may want to redirect entire swaths of content. Let’s say you had a blog with a url structure like:

http://www.my-blog.com/category/news/article-name....

You ported over all your thousands of articles to your new system but they have a new URL structure:

http://www.my-blog.com/news/article-name

It would be highly inefficient to go through each article and make a new redirect line. Wouldn’t it be nice if we could automate this process somehow? Is there a way to program this? Is this another contrived question leading to the point that I’m obviously about to make? If you answered “Yes” to all of the above, you’re correct! Rewrites are just what we need. A rewrite is different (but can be similar) to a redirect in that it actually rewrites the requested URL on the fly. This can be used in conjunction with a 301 flag to get the desired outcome. Take the following code example:

RewriteEngine On
RewriteRule ^/?category/news/(.*)$ /news/$1? [L,R=301]*

*Please note that to use this method, Apache must have mod_rewrite enabled. Again, if you aren’t sure, check with your hosting provider.

What we’re saying here is anytime a URI is accessed with category/news/any-article-name we want it redirected to /news/any-article-name. The “L” denotes that this is the last rule in the run and Apache should stop processing rules afterwards. The R=301 denotes that this is a permanent 301 redirect. Which leads us to the types of redirects.

301 - We’ve moved permanently. In fact, they tore down that old house. You couldn’t even go back there if you wanted to. Hey mail man, you will not have to deliver mail there again.

302 - This redirect is just temporary. The house is being renovated and we decided this was the perfect time to take a vacation. So, for the time being send our mail to this address, and we’ll let you know when we move back. In web terms, this kind of redirect is good for a temporary landing page that may be up for a promotion you’re running.

So them thar’s the basics. Most scripting languages have a way to implement 301s directly in the files themselves, so definitely use whatever is most effective for your situation.

The most important piece of information to take from this article is not how to implement your 301s, but that you need to do it. All that search engine juice you’ve built up over the years can be preserved (for the most part) by using this simple technique.

Not sure if things are redirecting or if you have your new site set up correctly? Give us a call. We're always open for a quick chat.