Common HTTP Redirects Explained: When and Why to Use Them

A redirect sends visitors from one URL to another. The type of redirect used depends on the specifics of the request and the wanted outcome. For example, a 301 redirect indicates a permanent move, ensuring search engines update their indexes, while a 302 or 307 redirect signals a temporary change, useful for maintenance or A/B testing without affecting SEO. Each redirect type ensures the appropriate handling of user requests and search engine behaviour, optimizing both user experience and website performance. These are the four most common types of redirects and the scenarios in which they are used best.

301 Redirects (Permanent Redirects)

A 301 redirect is a way to permanently send the user from one web address to another. When you try to visit a URL with a 301 redirect in place, the 301 redirect automatically takes you to the new address, ensuring you find the correct page. For example, if a website changes its structure and moves a page from oldsite.com/page1 to newsite.com/newpage, a 301 redirect will ensure you end up on the new page without hassle. This type of redirect also tells search engines to update their records so the new address gets the same ranking benefits as the old one. Additionally, the visitor’s browser will note this change, updating its internal cache.

308 Redirects (Permanent Redirects)

Like a 301 redirect, a 308 redirect will permanently redirect you from one web address to another. Where it differs from 301 redirects is that the original request method will remain intact. As a 301 redirect will alter the method used to a GET request, redirecting other methods like POST requires a different way of doing this so that the payload will stay intact.

302 Redirects (Temporary Redirects)

A 302 redirect is a way to temporarily send the user from one web address to another. When you visit a URL with a 302 redirect, the server automatically takes you to a different page, but it intends for the original URL to remain accessible. For instance, if a website is running a special promotion and temporarily moves its page from example.com/sale to example.com/promotion, a 302 redirect will take you to the temporary page. Unlike a 301 redirect, which signals a permanent change, a 302 redirect tells search engines that the move is temporary and that the original URL will return.

307 Redirects (Temporary Redirects)

A 307 redirect is used to temporarily send you from one web address to another, similar to a 302 redirect, but it keeps the original request method intact. If you’re trying to access a page that has a 307 redirect, you’ll be taken to the new URL without changing the type of request you made. For example, if a site moves its page from example.com/oldpage to example.com/newpage and you originally sent a form (POST request), a 307 redirect ensures your form data is preserved when you’re redirected. This is especially useful for ensuring that actions, like form submissions, are handled correctly during temporary changes.

Additional Resources

Redirections in HTTP

Fixing redirect issues