Redirection is a technique where users visiting a page through one URL is taken to a page identified by another URL. This is technically called URL Redirection or URL Forwarding. In SEO, the most commonly used HTTP Status Codes for redirection are 301 Moved Permanently, 302 Found, 303 See Other, 307 Temporary Redirect and 308 Permanent Redirect. These are response codes and messages issued by the server of a Website to any URL configured to redirect with such HTTP Redirect Status Codes. Redirect responses also include a ‘Location’ field that specify the URL to redirect to.
HTTP Redirects can be broadly classified as Permanent Redirections and Temporary Redirections. There are also some Special Redirections like 304 (Not Modified) and 300 (Multiple Choice). Now let us see the various Request methods before understanding how the HTTP Redirections work. HTTP Redirects are responses to HTTP requests for resources on a server. Hence it is important to understand the various HTTP Request Methods first.
- HTTP Request Methods
- HTTP Redirect Methods
- HTML Redirection
HTTP Request Methods
GET– The GET method requests a representation of the specified resource. The data, if any, is sent as URL parameters. These are also known as Query parameters. Requests using GET should only retrieve data from the server. In CMS like WordPress, these query parameters can be specified as part of the pretty URL. For example, in the pretty URL
https://wordpress.org/plugins/platinum-seo-pack/ the query parameters are “plugins” and “platinum-seo-pack”. In WordPress terminology, “platinum-seo-pack” is the Post Name or slug that uniquely identifies the page and “plugins” is the category or taxonomy under which the page is categorized or classified. Without a pretty URL, this can look something like
"p=1234" is the query parameter specified as a name value pair, p being the name and 1234 being the value. These URL parameters are available in $_GET superglobal variable in PHP.
To this request, the server responds with a header where the status looks like
GET: HTTP/2.0 200 OK. It also retrieves a response body, which consists of the page content that you see on the browser.
HEAD – The HEAD method asks for a response identical to that of a GET request, but without the response body. i.e. the server only responds back with the header where the status looks like
HEAD: HTTP/2.0 200 OK. There is no response body to this request.
POST – The POST method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server. In this method, the data is sent as part of the Request body and not as part of the URL. POST methods are more secure than GET method and the data can be sent in both text and binary forms. These data are available in $_POST superglobal variable in PHP.
PUT – The PUT method replaces all current representations of the target resource with the request payload.
DELETE – The DELETE method deletes the resource identified by the sepcified URL.
CONNECT – The CONNECT method establishes a tunnel to the server identified by the target resource.
OPTIONS – The OPTIONS method is used to describe the communication options for the target resource.
TRACE – The TRACE method performs a message loop-back test along the path to the target resource.
PATCH – The PATCH method is used to apply partial modifications to a resource.
Let us now see how the various types of URL Redirection works in response to these HTTP Request methods.
HTTP Redirect Methods
The need for HTTP Redirection arises when a URL on the Website becomes a Dead URL or Broken URL due to its content having moved to another URL. This usually happens in WordPress, when you change the Permalink Structure or the Post Name (Slug) for any Post URL. When this happens, the original URL gets broken and returns a HTTP 404 Error.
Permanent Redirection, as the name suggests, is permanent in nature and it means that the original URL should no longer be used but replaced with the new one i.e. the URL to which it is redirected to and specified against “Location” field in the HTTP Header. As a result, all automations like Search engine robots, RSS readers and any other crawler will update the original URL for the resource with the new URL over a period of time.
Temporary Redirection, as the name suggests, is temporary in nature and it means that the original URL should continue to be used. But since it is temporarily not accessible, the URL specified against “Location” field in the 302 HTTP Redirect response should be temporarily used for fetching the same content or resource. But this should not be cached and automations like Search engine robots, RSS readers and any other crawler will have to continue to look for the resource in the original URL and not update or replace it with this temporary URL.
Special Redirections are those HTTP Redirects which let the users to manually make the choice of executing the redirect by responding with 300 Multiple choice Status and where the HTTP Requests are conditional in nature, the server responds back with a 304 Not Modified HTTP response when the conditions are satisfied.
301 Moved Permanently – 301 is the HTTP Status Code and “Moved Permanently” is the HTTP Status Response. All GET methods remain unchanged while other methods like POST, PUT, UPDATE, DELETE etc. may or may not be changed to GET for subsequent Requests. This was introduced in HTTP/1.0 version and the response to 301 Status Code is cacheable.
This is how 301 Permanent Redirection is specified on the server side in PHP. The user is redirected to the URL specified against “location” in the response header.
header('HTTP/1.1 301 Moved Permanently'); header('Location: https://wordpress.org/plugins/platinum-seo-pack/'); exit();
The Status Code 301 Moved Permanently is most commonly used for redirecting users from one URL to the other URL where the content or resource is moved to. This is recognized by all search engines and hence it is commonly used for SEO whenever the URL (resource identifier) changes. For example in WordPress, when Permalink structure is changed or when the Post Name is changed, WordPress 301 HTTP Redirect is used to redirect users to the new URL.
308 Permanent Redirect – In this response, the method and body are not changed. i.e. all methods like POST, PUT, UPDATE, DELETE etc. will continue to remain the same and not change to GET for subsequent Requests. This was introduced in HTTP/1.1 version and it is cacheable by default.
This is how 308 Permanent Redirect is specified on the server side in PHP. The user is redirected to the URL specified against “location” in the response header.
header('HTTP/1.1 308 Permanent Redirect'); header('Location: https://techblissonline.com/platinum-wordpress-seo-plugin/'); exit();
Though search engines like Google treat 308 HTTP Redirect the same as 301 HTTP redirect for GET requests, this HTTP Response is not necessary for GET operation. 308 is commonly used for reorganization of a Web site with non-GET links/operations i.e. for operations other than GET like POST, PUT, DELETE, etc.
Temporary Redirections are more useful when you are testing a new page but do not want to permanently pass on the ranking signals accrued by the redirected page or URL.
302 Found (Moved Temporarily) – 302 is the HTTP Status Code and “Found” is the HTTP Status Response. All GET methods remain unchanged while others may or may not change. This was introduced in HTTP/1.0 version where the message sent back to the client was “Temporary Redirect”. This was changed to “Found” in HTTP/1.1. HTTP Redirect with 302 Status Code is not cacheable.
header('HTTP/1.1 302 Found'); header('Location: https://techblissonline.com/platinum-wordpress-seo-plugin/'); exit();
302 Found (Moved Temporarily) is more appropriate when the content is temporarily available at a different URL for a specific time frame. This HTTP response Code 302 tells the browser that the resource is available but temporarily on a different location. Search engines like Google and Bing are said to treat 302 as 301 after a period of time. i.e. the resource is considered to have permanently moved to the location specified with 302 HTTP Status Code.
307 Temporary Redirect – 307 is the HTTP Status Code and “Temporary Redirect” is the HTTP Status Response. All the Request Methods remain unchanged. This was introduced in HTTP/1.1 mainly for non-GET operations. i.e. operations other than GET. Where the HTTP request is POST, PUT, etc. and you want to do a temporary redirect without changing the method, the HTTP Status Code 307 is more appropriate. However, for all GET operations, you can continue to use 302 Found (Moved Temporarily).
303 See Other – 303 is the HTTP Status Code and “See Other” is the HTTP Status Response. The GET method remains unchanged but all other request methods are by default changed to GET method. This HTTP response code 303 is used to redirect after a PUT or a POST, so that refreshing the result page doesn’t re-trigger the operation and it is instead changed to GET.
300 Multiple Choice – This does not have any major use case. When this HTTP response is issued, the choices to redirect to are listed in an HTML page in the body. The user has to make the choice manually. This may be used to warn users that they are being redirected to another URL which might be on the same domain or another domain. So the users are forced to make the choice. However, search engine bots like Google prefer to have such alternate locations specified in Link headers with
rel=alternate attribute.For example, mobile friendly versions of a page may be shown against meta link tags in the HTML Head section of the content retrieved for the URL i.e. meta link tag specified with “rel=alternate” and “href” attributes in the head section of the HTML and the alternate URL specified against the “href” attribute.
304 Not Modified – This HTTP response is sent in response to conditional requests made commonly using
If-match conditional headers.
If-Modified-Since conditional header is sent with the
Last-Modified date in request header and the server responds back with “304 Not Modified” HTTP status when the requested resource has a date that is older than or the same as the Last-Modified date. The requested resource is not retrieved and sent back.
If-none-Match conditional request is made with the cached Etag and the server will respond back with “304 Not Modified” HTTP status when the requested resource has an Etag that matches it. The requested resource is not retrieved and sent back for this conditional request as well.
These type of URL Redirections are usually used when a user does not have access to the server.
HTML Redirection is a technique in which a page is redirected to another page by using a meta element in the head tag. The content attribute specifies the number of seconds the browser should wait before redirecting to the specified URL. As the name suggests, this type of redirection only works with HTML and it cannot be used for images or other types of content.
Final Thoughts and Recommendations
HTTP 301 Redirects and HTTP 302 Redirects are commonly used to indicate Permanent Redirection and Temporary Redirection respectively to Search Engines like Google, Bing and others. It is important to ensure that these kind of URL Redirections are properly done on Websites. It should also be ensured that there are no Redirect Loops and there are no Redirect Chains. If you are on WordPress, Platinum SEO Plugin help you make 301 Redirects and 302 Redirects easier.