What is a URL redirection?
HTTP redirections
HTTP redirections, also known as url redirect, web redirect or other similar names, are a web server mechanism which allows to tell a visitor that the web page he is looking for has been moved at a different address.
Hypertext Transfer Protocol (HTTP), the protocol behind the Web, defines a list of response status codes, which are associated to each and every Response sent by webservers. These status codes are numbers which have been standardized in several RFC. For example, a successful request receives a response with a 200
status code, while a "Not found" error gets the famous 404
code. For redirection responses, the HTTP specification defines several status codes, more or less widely used: 301
, 302
, 303
, 307
or 308
. All these status codes have different meanings and implications:
-
301
and308
are meant for permanent redirections; -
302
,303
and307
are used for temporary redirections.
Permanent vs Temporary redirections
Permanent and temporary redirections produce the same visible effect for the visitors, who get redirected to other pages. However, there are important differences:
- permanent redirections have a permanent effect. In other words, using a permanent redirection is the right way to indicate a client that the original content has moved to a new address, and that this change is permanent and won't change in the future. typically, web browsers will cache permanent redirections in order to speed up the content resolution, and search engines may update their indices to save the new destination URL. From a SEO point of view, permanent redirections also have the benefit of transferring the SEO weight to the destination URL.
- on the other side, temporary redirect are the right way to tell the browser that the redirection must be done, but that the content could be again available, or that its target is temporary and may change in the future. Temporary redirects do not have a SEO weight effect.
While building your redirection plan, you can either choose permanent or temporary redirections. Just keep in mind that permanent redirects are a danger zone, as a mistake cannot be undone and may damage your SEO. The counterpart is, a permanent redirect helps search engines update their database to give more weight to the new url, a phenomenon called "link-juice".
Our "rule impact" feature helps evaluate the effect of a new redirection rule. Before publishing a rule, you can check that it won't affect your real web traffic in a wrong way!
If you are unsure about the validity of a redirection rule, a good strategy might first be to create a temporary redirect and, once you have tested its effect, change the status code to choose the appropriate one.
How to choose the redirection status code?
The various redirection status codes do not produce the same behavior in web browsers:
-
301
means Moved Permanently: the current request and all future requests should be redirected to the new URI, and this redirection is cacheable; -
302
was initially defined as Moved Temporarily (RFC 1945) but has since been redefined as "Found" (RFC 2616) in HTTP/1.1. Such a response code invites the web browser to make a second request to the target url, and allow them to rewritePOST
toGET
-
303
means See Other is usually used when the server does not have a representation of the target resource. In this case, the browser must perform aGET
request to the target url (even if a different method was used in the initial request); -
307
is a Temporary Redirect and is available for requests performed using HTTP/1.1. the behavior is the same like a302
, except the method is kept. Hence, if aPOST
request gets a307
response, the browser will try a newPOST
method to the new location; -
308
states Permanent Redirect and has been defined quite recently, in RFC 7538, though it is compatible with most of the modern browsers.
SEO recommendations varies on the topic. From a purely technical point of view, you should now use the 307
/308
http status codes, provided the user-agent supports it and the requests have been made using HTTP/1.1
. Otherwise, you should prefer the more classical 301
/302
, but those do not provide the same comfort for the end-user (particularly during form submissions).
As of now, the general SEO litterature recommends to stick with 301
and 302
redirect codes. From a purely SEO point of view, prefer the 301
status code, keeping in mind that 301
responses are cached by web browsers, and are therefore not suitable for redirects that may change in the future.
What are redirect chains and loops?
When a normal redirection happens, the browser of the visitor is instructed to change the URL of the request, and to perform a new request to this new URL:
Redirection chains happen when a request to a given URL of your website is redirected to another URL that is itself redirected. A redirect chain can have 2 "hops" (there will be two successive redirects), or sometimes more (3, 4, 5, etc. consecutive redirects):
If one of the successive redirect location is one of the previously requested URL in the chain, then there will be a redirection loop:
This is obviously a situation that you will really want to avoid, because:
- the browser of the customer will send a new request at each "hop", which causes many network transfers;
- the browser will refuse to continue after more than 10 to 20 redirects (depending on the browser). After this, the end user will see a browser error message indicating the misfunction of the redirects;
- each request goes through the hosting platform of your website, and many such issues could cause a high load and eventually slow down your website.
redirection.io helps avoiding such situations, thanks to the "Impact" test that is displayed each time you create a new rule. If a redirect chain or a redirect loop is detected on one of the examples attached to the rule, you will see a warning like