A redirect is a response that is given by a webserver, that asks the user agent to not show the response body, but instead request a different resource.
The HTTP protocol provides 2 methods of redirection, a
302 temporary redirect and a
301 permanent redirect. There are some more 300 status codes you can find a complete list here. User agents and clients must adjust accordingly when a 301 redirect is given so that future requests for the same URL won't be requested in favor of the permanent redirect.
A redirect in HTTP is used for various purposes:
- To perform load balancing.
- As part of the post-redirect-get pattern.
Server-side languages such as PHP can edit the HTTP headers to create a redirect. In PHP:
header('Location: redirectedTo.php', TRUE, 301);