August 1, 2017

301 Redirects Explained

The internet isn’t a big truck you put your website on. It’s a series of tubes.

Moving sucks. Packing boxes, losing stuff, hurting your back lifting that one really heavy thing even though you know you should be more careful. It’s a nightmare and nobody likes dealing with it. Moving your website to a new domain can feel just as brutal. The only difference is the internet isn’t a big truck you put your website on. It’s a series of tubes.

When you launch a new version of your site, move to a new domain, shut down a popular landing page, or do basically anything that disrupts or changes traffic flow on your website, you can lose search ranking. This is because the internet needs time to catch up to the changes. The first few weeks after a move, a lot of traffic is going to come in looking for old pages that don’t exist anymore.

This is similar to how letters and packages might go to your old house after you’ve moved into your new one. To solve that problem in real life, you need a mail forwarder from the post office. On the internet, you need a 301 redirect!

Think of a web server as a big mail sorting machine. All the requests for different pages come into it and then it has to decide where to put them all. The problem is that when you move, you still might get mail to your old address slot, so you need to let the post office know that mail needs to be forwarded to your new address. Without that instruction, the mail carrier isn’t going to know what to do with the letter, so they will just return it to the sender.

Let’s imagine you live in an apartment building, and your friends Pete and Steve live on either side of you in their own apartments. One day, Pete gets a job in another city and moves out, but you notice a bunch of letters piling up by his door because he didn’t forward his mail. This is the same thing that happens when you move your website without a 301 redirect. A bunch of old requests and traffic end up piling up with nowhere to go.

This is also how it works with a web server. If you move servers, the requests still come in the exact same way, but a new server or website doesn’t always have the files to serve all those page requests properly.

Now, let’s imagine your other friend Steve gets a promotion and a big raise, so he decides to move to a new apartment on the top floor. Steve, always the responsible friend, also remembers to forward his mail up to his new apartment. Any letters addressed to Steve in 4B get redirected to Steve in 14B. This only happens because Steve informed the post office he was moving, so they could route his mail accordingly.

In the same way Steve let the post office know to forward his mail, you need to let your new web server know how to forward your traffic. Giving your new server instructions on how to handle page requests it does not have the correct files for reduces the chance of an error. Typically, if a server receives a request for an old page it does not have the files for, it will return a 404 error. However, if you know what the old page requests coming in will be, you can give the new server some special instructions to serve a different file in its place. This is the basic idea behind 301 redirects.

301 redirects should not be complicated or difficult to handle — it should be as simple as forwarding your mail. The only thing you should need is a list of the old URLs that traffic is still going to and the new URLs you want the traffic to reach. Some websites will have a sitemap.xml file or some other list of all the pages and URLs currently on the site, which you can use to start mapping your redirects.

It can also help if your site uses Google Analytics or other tracking software, so you can determine what your most popular URLs are to make sure you are redirecting that traffic to your new host correctly. It might not be obvious, but some of the most popular areas of your site may be older blog posts or pages that rank well in specific Google results. Maintaining this traffic is the key to keeping a consistent page ranking on Google so results from your site do not fall further down the page.

Once you have a complete list of redirects, you can use a variety of methods in order to implement them. We primarily use the WordPress CMS at Reaction, and there are a number of 301 redirect plugins that work with the platform:

  • Redirection — This is one of the most popular WordPress redirect plugins on the market. Simple to use, great feature set, and totally free! You can’t go wrong.

  • Yoast SEO Premium — We are big fans of Yoast’s SEO plugin, and the premium version includes a redirect manager. If you need an all-in-one SEO solution as well as a redirect manager, this is a solid bet.

  • Safe Redirect Manager — While it doesn’t offer as many features as Yoast or Redirection, this plugin still provides a decent portal to manage 301 redirects on your site. As a bonus, it only redirects to whitelisted hosts, which helps to avoid any nasty security issues.

You can also perform 301 redirects using just PHP code or by manipulating your web server’s configuration files directly. However, these methods are a little more technical and If you’d like there is a great blog post from webconfs.com that details how to perform 301 redirects with htaccess, IIS, PHP, ASP, Javascript, and a few other popular languages.

301 redirection can seem overwhelming but, unlike moving to a new house, it’s actually a fairly simple process. The most important thing is taking a complete inventory of your current incoming traffic so you know exactly where the redirection has to occur. After that, it’s just a matter of passing that information to your web server and making sure everything is working properly. If moving in real life were this easy, people would do it more often.