What is a 301 redirect? Everything you need to know

Steven Monetti
min read
February 23rd, 2017

You’ve probably heard the words 301 redirect before, but what is it, really? In layman's terms, you are creating an alias URL for your real URL. You are telling everyone that an old URL has been permanently moved to a new URL.

When do people use it?

There are several scenarios in which a 301 redirect serves a very good purpose. Although each one does have one purpose or another, here are the two most common:

CHANGING URLS

Here’s an example:


The following blog article has lived for quite some time now...

https://www.herosmyth.com/blog/real-time-applications-rails-5-and-actioncable

But...what if today we wanted to change it, or we found a spelling mistake in it? If we were to change the URL without creating a 301 redirect, then people going to that link would get a "Page not found" error because that URL would not exist anymore. Even worse, Google would soon realize that this page does not exist without recognizing that it actually moved somewhere else.

SHORTENING URLS

Shortening URL services like Bit.ly and Goo.gl are a good way to transform your long URLs into short ones. What they are actually doing is creating a small URL that outputs a 301 redirect to your location.

What about SEO?

One of the main reasons why people use 301 redirects is because the URL forwards 90 to 99 percent of its SEO (ranking) value to the location of its redirect. Google and other search engines will also understand that that URL has been permanently moved to a new location, and they will therefore remove the URL from their databases.

How do I find where a short URL redirects to?
If you are curious about where a short URL redirects to without actually clicking the link or pasting it into your browser, you can run a small piece of code into your MacOS terminal.

curl --verbose "http://bit.ly/2fLZpOq"

Or you can more easily use this online service: https://www.hurl.it/

Every HTTP request returns a few different things: Status Code, Headers, and Body. Remember that a 301 redirect is only issued by the browser itself, so when you make an HTTP request via other programs, you will get the raw values of what that URL returns.

A 301 redirect will return the following two things:

  1. An HTTP Status Code value of 301.
  2. A header called "Location" with the value being the location which the user should be redirected to.

301 Redirect CURL request

Comments