What is a 301 redirect and what is it?
When we speak of redirects, we refer to an http response code that we put on our server, for the robots to search this page no longer exists, and in its absence we exchange it for another.
That is to say, to easy and convenient manner, we shall say that a redirection (regardless of his response code, either 301, 302, 307...), is when a user wants to access a url in concrete (e.g. www.ejemplo.com/hola), and it is redirected to another url directly (www.ejemplo.com/hola2).
When do we conduct a 301 redirect?
When we set up a 301 redirect, we are telling the server that the url, 1, now it will not load, and by default, you should direct the user to another page (url 2). The peculiarity of which is 301, it is because this action is defined as permanent.
But... for what reasons we might be interested in, perform a 301 redirect? Here are a few:
- We are doing a migration of websites.
- We have two urls with content like this, and they are competing with each other: In this case, there will usually be to look at which of the two has less traffic, and redirect that is “more poor” to the one that receives the most traffic.
Very important: when you apply a response code of 301 to a url, we have to take into account that this applies ONLY in cases that someone from outside of our web site, you want to access the old url (either because they have saved, or because it is used to enter). That's okay, because in the end you are doing that when a user gets to the old url, go to the new instead of getting to a url that does not exist.
What is not good (and this is one of the errors which we explain in our other article where we talk about what is Screaming frog and how it works), is that when a user is navigating within the site, click a link, and this will be carried to the final url after going through the old. With that what we are doing, is that the Google bot will take more time tracking down the site, because it gives more laps to stop coming to the url that we are interested in.
In summary: apply a 301 is not wrong (sometimes even necessary), but it is important that we do not find any when we're navigating to an internal site. If you have an old url that we are redirecting to the new one, in this site we will directly change the link towards the end. Thus, when a user who is browsing in the web one click, you will be taken to the final page new.
Types of redirects
So, what http response codes we can find? The answer to this question is: MANY. But the interest we see today, is the different gamma response codes that we have when we go to do a redirect. Below, we detail each one of them, though as I move to the more common, and you'll see most often are these 3: redirect 301, 302 and 307.
- Redirection 300 Multiple Choices: Speak to us multiple options to the URI that the user can access. Example: Different format options for video.
- 301 redirect or Moved Permanently: This is the most common, and its meaning is “from now on this url does not already exist, and in its place I will take you to this other url.” This action is permanent and lasting in time.
- Redirect 302 Found (previously known as “Moved Temporarily”: This code, originally used to inform you of a temporary redirection, or momentary. Today (in theory), it has spread to the 303, or 307, but many sites still using. Ex: When the user wants to access a content that is located within a private area in which you have to sign in. In this case, the user is redirected to the screen of “sign-in”.
- Redirect 303 or See other: This response can be found under another URI using the GET method.
- Redirection 304 or Not Modified: This type basically informs us that it has not changed the action of the url from the last time that you said.
- Redirection 305 or Use Proxy: This type is useful for us because it tells us that many HTTP clients are not governed by the code of the standard response of the request.
- Redirection 306 or Switch proxy: This response code is not currently used, but is maintained by if in the future they need in order to attribute to some other type of response.
- Redirect 307 or Temporary redirect: We speak of this kind, when we find that a redirect would have to have been made with another URl, but has been provided.
- Redirection 308 or Permanent Redirect: Finally, this latter tells us that the resource is located in another place, and that change is permanent.
How to set up a 301 redirect
Here, we are going to tell you the two most common means of carrying out a 301 redirect:
By .htaccess
In this case, the steps to follow are simple:
- Access to our FTP (we can do this by entering our hosting same).
- We look for the file “.htaccess file” and enter to edit it.
- And depends on the action that we want to carry out, do one thing or another. Then, here are the most common actions.
To move a domain
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://dominio.com/$1 [R=301,L]
To move to a subdomain
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} *!^www*.diminio\.org [NC]
RewriteRule (.*) http://www.dominio.org/$1 [L,R=301]
To move a directory
RedirectMatch 301 ^/viejo-directorio/(.*)$ http://dominio.com/nuevo-directorio/$1
Redirect a single url
Redirect 301 /antigua-pagina/ http://dominio.com/nueva-pagina/
Using a CMS
If we do not have FTP access to the web (either because we are not programmers, or because we're using a CMS, and we do not want to complicate life), we must give you a good news:
There are add-ins (in wordpress are called “plug-ins”, in prestashop “module”,etc) that allow you to perform the redirection of a more easy and comfortable.
In the store, add your CMS, you will find many to choose from. There is none better than another, it is simply choose the one that most suits you, and then run this function.
Advantages and disadvantages of conducting a 301 redirect
Then (and already for the end of the article), let's look at some points that play in favor of doing a 301 redirect (that is to say, we will favor), and others that we must have in mind when we take such action.
Benefits of doing a 301 redirect:
- Troubleshoot duplicate pages or canibalizan between them.
- In the case that we delete a page, to avoid that the user gets to a url that no longer exists, turning it back towards the new.
- Along with the previous point, when we redirect one or more pages to a url in particular, what we are doing is to concentrate the force of all the others, in the final url.
- They are essential when we want to do a migration from one site to another.
Damages do a 301 redirect:
- When you do a redirect from one url to another, no one assures you that the other url to retain the same positioning that had the first. In fact, in the majority of cases are already in a loss of position (at least momentarily).
- Is it harmful to leave redirects internal to the site. If a category old it is redirecting to another url when you navigate the site, should be accessed directly to the final url.
- Warning: it is Not recommended to do redirections 301 frequently. Only in cases where it is necessary, and to be able to first check the traffic that you are receiving the url that will be redirected.