Sometimes, keeping your website running smoothly means sending traffic in a new direction. If you’ve deleted an old page, updated your site structure, or moved to a new location, you’ll want to redirect users and search engines to the new page so they don’t wander off to a rival’s site.
Redirects ensure visitors land where you want them, even if they’re clicking an outdated link. They’re also useful for tracking marketing efforts or testing different URLs. But not all redirects work the same way—and using the wrong one can send mixed signals to search engines or frustrate users.
That’s where HTTP status codes can help. Specifically, 301 and 302 redirects tell search engines whether a move is permanent or temporary. Let’s break down when and how to use each so you can keep your site optimized and your users headed in the right direction.
What is a 301 redirect?
A 301 redirect is a permanent redirect. It tells visitors and index bots (i.e., automated programs used by search engines to crawl and catalog web pages) that a specific page has moved permanently to a new URL.
A 301 redirect tells visitors they should no longer use the old URL, while preserving the old URL’s rank on search engines. Over time, Google and other search engines will update their index to the new permanent URL and stop indexing the old webpage URL.
When to use a 301 redirect
Here are some cases where a permanent redirect may be useful:
Changing domain name
If you’re rebranding or renaming your company, you’ll likely need to change domain name. Use a permanent redirect so customers trying to visit your old site end up at your new one, with limited traffic loss due to 404 errors. Using a 301 redirect will send site visitors to the right place without sacrificing the power of the old site’s rank.
Switching from HTTP to HTTPS
A big part of upgrading an older insecure site using HTTP to a more secure encrypted HTTPS site is redirecting your users to the new versions of your website’s pages. Because Google and other search engines prefer HTTPS sites, and many modern browsers will warn users if you’re using HTTP, you end up preserving your search engine rankings if you permanently redirect your traffic to the HTTPS site.
Consolidating duplicate content
Sometimes, your website may have the same content on different pages. Having the same content on more than one page can split link equity and harm your search ranking. Consolidating all these URLs to point to a single page will help put all your SEO value into one page, instead of splitting it.
Deleting or renaming pages
Sometimes, when you redesign a site, you may rename pages with shorter updated URLs, or change the site structure to serve customers more efficiently. If your users or search engines access these old pages, they will get a 404 error, which harms your ranking. A permanent 301 redirect makes sure users and search engines will get where they need to go even after you’ve restructured categories, updated page slugs, or simplified your URLs for usability or SEO rank.
What is a 302 redirect?
A 302 redirect, by contrast, will temporarily redirect users. Users are directed to a temporary new link, but Google and other search engines keep indexing the old URL. It doesn’t transfer the SEO value to the new URL.
When to use a 302 redirect
A 302 redirect tells search engines the move is only temporary. Here’s when you might opt for this type of solution.
A/B testing different page designs
You might want to A/B test two versions of a product page to see which one converts better. In this case, you’ll want to redirect users to one of the test pages, but only while you’re tracking which one converts better. Once you know which product page performs best, you can change the temporary redirect to a permanent one.
Conducting website maintenance
If your site is down for maintenance, you don’t want your users to get 404 errors and lose trust in your site. Instead, use a temporary redirect to send them to a status or maintenance page. A search engine database won’t remove your home page this way, and they won’t transfer any link juice or equity to your maintenance status page. Once the maintenance is complete, remove the redirect and all traffic will flow to your site as usual.
Making location-based offers
Let’s say you have a set of products you want to offer on sale to users in Canada, but not the US. You can create a specific page for a Canada-only holiday, redirect only Canadian visitors to it, and remove the redirect when the sale is over.
Temporarily removing a page
If a specific product is out of stock, you might want to temporarily send site visitors to a similar page with a 302 redirect. Once you restock, you can remove the redirect code.
301 vs. 302 redirect: What’s the difference?
The main differences between a permanent 301 and a temporary 302 redirect are their duration and how search engines like Google treat them.
Using these correctly will help you maintain the SEO value of your pages whether you’re passing that value to a new URL (permanent 301 redirect) or retaining it for later (temporary 302 redirect). This is especially true when search engine refreshes occur—a process in which a site like Google re-crawls and re-indexes websites to reflect any changes in content, structure, or URLs.
Here are the similarities and differences, in detail.
How are 301 and 302 redirects the same?
Both types of redirects send users to a different URL and both use the location header in the HTTP response. This tells the browser which new URL to go to.
Browsers handle both automatically, which means your users won’t know the difference in practice—they will just end up at the URL of your choice. Both 301 and 302 redirects maintain the same functionality for users, too, as all the forms, links, and sessions continue to work, regardless of the redirect type.
You can set up both types of redirect using the same server tools your site already uses, like .htaccess file, Nginx, PHP, JavaScript, or server-side logic. No extra setup or third-party tools are needed.
How are 301 and 302 redirects different?
The 301 redirect indicates a page has moved permanently. Search engines then update their index and pass most of the SEO value to the newly defined URL, which helps maintain your rank on search engine results pages (SERP). Typically, 90% to 99% of the page’s existing ranking power in terms of backlinks, domain authority, and relevance is passed on to the new URL.
Some of the lost ranking power can happen when you have a complex redirect chain (i.e., you implement redirects from one URL to another, then to another, and so on). This compounds as the link chain gets longer and longer. The best practice is to use a single redirect from one URL to another.
A temporary 302 redirect, by contrast, tells search engines the page has only moved temporarily and lets them know to keep the original URL indexed for when it comes back. It generally doesn’t pass link equity to the new URL and browsers may not cache the redirect.
301 vs. 302 redirect FAQ
Should I use a 301 or 302 redirect?
If you need to permanently send site visitors and search engines to a new location, you should use a 301 redirect. This can be because you’ve changed your domain name or site pages, are consolidating multiple pages, or are switching from an HTTP to an HTTPS site. Use a 302 temporary redirect when you need to redirect users for a short period of time, like during a regional sale or when you’re A/B testing.
What is an example of a 301 redirect?
You might want to permanently move a product page from an older product to a newer one. Your old page might be named https://www.example.com/widget and your new page might be named https://www.example.com/new-widget.
How do I fix a 302 redirect error?
Typically, a 302 redirect error happens when there’s an unwanted or incorrect temporary redirect on your site. It could be that the redirect isn’t sending users where you want it to. To fix this, edit your redirect code to make sure the page you’re redirecting to is the correct one.
If your redirect should have been a permanent redirect (the SEO value isn’t getting passed to the new URL), use a 301 redirect. This should pass the correct SEO value to the new page.
If a redirect chain causes a loop between two pages, confusing search engines, look at your redirect chain. Make sure the redirect ends cleanly on a new destination, not back within the chain somewhere.