What is Redirect / Redirection?

Redirect / Redirection

Redirect is a script that automatically sends a user that is trying to open a web page to another web page.

redirect

Redirect is a useful thing that helps to fight “404 Not found” errors, though it’s also widely used by unwanted ads. There are several types of redirect scripts:

  • “300” Multiple Choices (the destination has several options to choose from);
  • “301” Moved Permanently (the destination is moved forever);
  • “302” Temporary Moved (the destination is moved temporarily);
  • “303” See Other (the requested resource can be found at another address);
  • “304” Not Modified (the content didn’t change, only address did - this can be used for drawings, style sheets, etc.);
  • “305” Use Proxy (access must be granted through a proxy only);
  • “306” (Unused) (the destination address is not used anymore);
  • “307” Temporary Redirect (only current request will be redirected);
  • “308” Permanent Redirect (the current request and all future requests will be redirected).
The most common type is “301 Moved Permanently”. It’s the most widely used type of redirect scripts. It’s useful when a web page the visitors will be looking for is permanently moved to a new domain, so it automatically opens proper web page. The user opens the browser and enters something like http://oldsite.com in the address bar. Presses the Enter button. The browser generates an HTTP request and sends it to the server and the server returns an HTTP response. If the domain has the 301 redirect enabled, then in its “Location” field the new address of the page will be specified, like http://newsite.com, where the user will be redirected. This was a so-called redirect. You’ve been redirected from one web page to another. What for it may even be necessary? Why such difficulties? The fact is that in the process of developing a website many things can change in its structure:

  • Some pages have been moved to another place
  • The general structure of the web site has changed
  • The owner decided to change the domain name of his site
In all these cases, if you refer to the page using the old address without redirect, the server won’t be able to provide the necessary information and will generate the 404 error. A simple example of 301 redirect on PHP:

<?php
Header( "HTTP/1.1 301 Moved Permanently" ); 
Header( "Location: news.php" ); 
exit();
?>

For the most widespread CMS platforms like WordPress or Joomla there’s a bunch of redirection plugins. They can ease redirection management without the deep knowledge of the markup languages. For example, Redirection, Simple 301 Redirects and SEO Redirection Plugin for WordPress and ReDJ or jRedirects for Joomla.

Related terms:

СMS, PHP, JavaScript

References and further reading: