
- HTTP - Home
- HTTP - Overview
- HTTP - Parameters
- HTTP - Messages
- HTTP - Requests
- HTTP - Responses
- HTTP - Methods
- HTTP - Status Codes
- HTTP - Header Fields
- HTTP - Caching
- HTTP - URL Encoding
- HTTP - Security
- HTTP - Message Examples
- HTTP - Versions
- HTTP - Connection Management
- HTTP - Content Negotiation
- HTTP - Redirection
- HTTP - Authentication and Authorization
- HTTP - HTTP over TLS(HTTPS)
- HTTP - HTTP/2 and HTTP/3 Features
- HTTP - API Design Considerations
- HTTP - Troubleshooting
HTTP - Redirection
HTTP redirection is a process where a client can be automatically redirected to another URL. The server uses specific status codes, along with the new URL where the client should send their request. HTTP redirection serves various purposes such as guiding users to a new resource, managing URL changes, or website restructuring.
Types of Redirections
Permanent Redirections
Permanent redirections indicates that the original URL has been replaced with the new one permanently. Users and clients should use the updated URL to access the resource. Different types of permanent redirections are mentioned below:
301 Moved Permanently
The 301 Moved Permanently status code indicates that the requested resource has been permanently moved to a new location.
Uses:
- It is used in domain migration when a website changes its domain name.
- It is used to improve SEO by updating old URL structures.
Example:
GET http://httpstat.us/301?url=https://www.example.com HTTP/1.1 User-Agent: PostmanRuntime/7.43.0 Accept: */* Accept-Encoding: gzip, deflate, br
Output

308 Permanent Redirect
It is similar to 301 but in this redirection, HTTP method remains unchanged. The client must follow the new URL permanently. The request method and the body doesn't get modified by the client in the redirected request.
Uses:
- It is used when you want clients to use new URL while preserving the HTTP method.
- It is used in API versioning where server wants clients to update their requests to new endpoint without changing the HTTP method.
Example:
GET http://httpstat.us/308?url=https://www.example.com HTTP/1.1 User-Agent: PostmanRuntime/7.43.0 Accept: */* Accept-Encoding: gzip, deflate, br
Output

Temporary Redirections
Temporary redirections indicates that the original URL has been replaced with the new one temporarily. Users and clients should keep using the original URL to access the resource. Different types of temporary redirections are mentioned below:
302 Found
It indicates that the requested resource has been temporarily moved to a new URL.
Uses:
- It is used during temporary maintenance of server, moving clients or users to temporary page.
- It is used for redirecting users to test new version of any webpage.
Example:
GET http://httpstat.us/302?url=https://www.example.com HTTP/1.1 User-Agent: PostmanRuntime/7.43.0 Accept: */* Accept-Encoding: gzip, deflate, br
Output

303 See Other
It indicates that the resource can be found at another URL and should be retrieved using the GET method. It is typically used after a POST request is successfully processed.
Uses:
- It is generally used after a form submission for redirecting the users to another page i.e confirmation page.
Example:
GET http://httpstat.us/303?url=https://www.example.com HTTP/1.1 User-Agent: PostmanRuntime/7.43.0 Accept: */* Accept-Encoding: gzip, deflate, br
Output

307 Temporary Redirect
It is similar to 302 but in this redirection, the HTTP method must remain same.
Uses:
- It is used for temporary URL relocation, when a resource is temporarily moved to different URL but should use the same HTTP method.
Example:
GET http://httpstat.us/307?url=https://www.example.com HTTP/1.1 User-Agent: PostmanRuntime/7.43.0 Accept: */* Accept-Encoding: gzip, deflate, br
Output

Special Redirections
Special redirections are unique redirection status codes which provides information and are neither permanent nor temporary but serve specific purposes. Different types of special redirections are mentioned below:
300 Multiple Choices
It indicates that the requested resource has more than one response and the user should choose one among available responses.
Uses:
- It can be used to select most suitable content format such as JSON, XML, and HTML.
- It can be used to choose a language out of various language provided by server.
Example:
GET http://httpstat.us/300?url=https://www.example.com HTTP/1.1 User-Agent: PostmanRuntime/7.43.0 Accept: */* Accept-Encoding: gzip, deflate, br
Output

304 Not Modified
The 304 Not Modified response tells the client that the requested resource has not been modified.
Uses:
- It is used in web browser caching to check if the resources like images, CSS, and JavaScript files has been modified since last visit or not.
Example:
GET http://httpstat.us/304?url=https://www.example.com HTTP/1.1 User-Agent: PostmanRuntime/7.43.0 Accept: */* Accept-Encoding: gzip, deflate, br
Output
