Choosing between a 301 and a 302 redirect looks like a technicality, but it decides which URL Google keeps in its index. Use a temporary redirect for a permanent move and your old URL can linger in search results; chain three redirects together and every visitor waits longer. This guide explains 301 vs 302 redirects, where 307 and 308 fit in, and exactly how to set each one up on Apache, Nginx, Cloudflare, WordPress and Shopify.
Key takeaways
- Use a 301 or 308 for permanent moves, as Google treats them as a strong signal that the new URL should be canonical.
- Use a 302 or 307 only when the original URL will come back, because Google may keep showing the old URL in results.
- Point every old URL straight at its final destination in one hop and keep redirects in place for at least one year.
- Do not redirect lots of deleted pages to the home page, as Google may treat this as a soft 404.
301 vs 302 vs 307 vs 308 at a glance
All four send the browser to a new address using a Location header. They differ in two ways: whether the move is permanent or temporary, and whether the browser may change the request method (for example turn a form POST into a GET).
| Code | Name | Permanent? | Method kept? | Typical use |
|---|---|---|---|---|
| 301 | Moved Permanently | Yes | Not guaranteed | Page or site moved for good |
| 302 | Found | No | Not guaranteed | Short-term swap, A/B test, temporary promo |
| 303 | See Other | No | Changed to GET | After a form submission |
| 307 | Temporary Redirect | No | Yes | Temporary move where forms or APIs post data |
| 308 | Permanent Redirect | Yes | Yes | Permanent move where forms or APIs post data |
MDN explains the history: 301 and 302 were never meant to allow a method change, but some browsers changed POST to GET anyway. 307 and 308 were created to remove that ambiguity, so they always keep the original method and body.
For an ordinary web page that people simply visit, the method doesn't matter. The decision that matters for SEO is permanent versus temporary.
How Google treats each redirect
Google's documentation is clear:
- 301 and 308 are permanent. Google treats them as a strong signal that the target URL should be the canonical version of the page, so the new URL usually replaces the old one in results.
- 302, 303 and 307 are temporary. Google follows them but treats them as a weak canonical signal, so the old URL may stay in results.
- Google says it handles 301 and 308 the same way in practice, and 302 and 307 the same way, but recommends using the code that matches your intent because other clients rely on the meaning.
Ranking signals pass through all of them. The old idea that 302s "lose link equity" isn't how Google describes it today. The real risk with a 302 used for a permanent move is that Google may keep indexing and showing the old URL, which is confusing for users and slows down a migration.
Other redirect types, in order of preference:
- Server-side HTTP redirects (301, 302, 307, 308): always the first choice.
- Meta refresh: Google treats an instant (0-second) refresh as permanent and a delayed one as temporary. Use it only when you can't configure the server.
- JavaScript redirects: Google may not see them if rendering fails, so use them only as a last resort.
When to use a 301 (or 308)
Use a permanent redirect whenever the old URL is never coming back:
- Moving from HTTP to HTTPS (see our guide to redirecting HTTP to HTTPS)
- Choosing
wwwor non-wwwand redirecting the other - Changing domain, for example
.co.ukto.comorexample.comtoexample.ca - Renaming a page, changing a URL slug or restructuring categories
- Merging two similar pages into one
- Retiring a product and sending visitors to its direct replacement
Pick 308 instead of 301 only if non-GET requests hit the old URL, such as forms or API endpoints. For normal pages, 301 is the most widely supported choice.
Google's site move guidance says to keep redirects for as long as possible, generally at least one year, so search engines and other sites have time to update. In practice, leaving them in place indefinitely costs very little.
When to use a 302 (or 307)
Use a temporary redirect only when you genuinely intend to bring the original URL back:
- A product page temporarily sends visitors to a "back soon" page
- A seasonal landing page takes over for a few weeks
- You're running a short A/B test across two URLs
- Geo- or language-based routing where the original URL remains the main address
If a "temporary" redirect has been in place for months, it's almost certainly permanent: change it to a 301.
How to set up redirects on each platform
Apache and cPanel (.htaccess)
On most shared hosting, you add rules to the .htaccess file in your site's root (cPanel's Redirects tool writes them for you).
# Single page, permanent
Redirect 301 /old-page/ https://www.example.com/new-page/
# Temporary
Redirect 302 /summer-sale/ https://www.example.com/offers/
# Whole site to HTTPS and www, in one hop
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [L,R=301]
Back up .htaccess before editing; a typo can take the whole site down with a 500 error.
Nginx
# Single page
location = /old-page/ {
return 301 https://www.example.com/new-page/;
}
# Whole host to HTTPS
server {
listen 80;
server_name example.com www.example.com;
return 301 https://www.example.com$request_uri;
}
Run nginx -t to test the configuration before reloading.
Cloudflare
If your DNS records are proxied through Cloudflare (orange cloud), you can redirect at the edge before requests reach your server.
- Single Redirects (under Rules) handle patterns such as
http://tohttps://or old folder to new folder. The free plan includes 10 Single Redirect rules per domain, with wildcard support but no regex. - Bulk Redirects handle long lists of one-to-one URL redirects. On the free plan you get up to 10,000 URL redirects across lists.
- Rules products take precedence over older Page Rules when both match, so remove overlapping Page Rules to avoid surprises.
Choose the status code (301, 302, 307 or 308) in each rule's settings.
WordPress
- When you change a published post's slug, WordPress usually redirects the old URL automatically, but don't rely on that for big changes.
- The free Redirection plugin lets you add 301, 302, 307 and 308 redirects and logs 404s so you can spot missing ones.
- Rank Math includes a redirect manager; Yoast offers one in its premium version.
- If you also redirect in
.htaccessor Cloudflare, document where each rule lives so they don't conflict.
Shopify
- Go to Content > Menus > View URL redirects and choose Create URL redirect.
- Enter the old path in Redirect from and the new URL in Redirect to, then save. It takes effect straight away.
- For many redirects, use Import with a CSV file.
Two Shopify quirks: redirects only work when the old URL is broken, so if the old product still loads, the redirect is ignored (set it to draft or delete it first). And some paths, such as /cart, /orders and /collections/all, can't be redirected. Standard stores can create up to 100,000 redirects.
Wix and Squarespace
Both have a URL redirect manager in their SEO settings (Wix: URL Redirect Manager; Squarespace: URL Mappings). Squarespace's mapping syntax lets you specify 301 or 302 at the end of each line.
Redirect chains and loops
A redirect chain is when one redirect leads to another: http://example.com to https://example.com to https://www.example.com to https://www.example.com/home/. Google's crawlers follow up to 10 hops by default, but every extra hop adds a round trip for visitors and gives crawlers more to process.
Fix chains by pointing every old URL straight at its final destination in one hop. After a migration, also update internal links so they point to the final URL rather than relying on redirects at all. Our guide to broken links and redirect chains covers clean-up in more detail.
A redirect loop is when the chain never ends, for example A redirects to B and B redirects back to A. Browsers show a "too many redirects" error and the page never loads. Common causes:
- Cloudflare's SSL mode set to Flexible while the server also forces HTTPS, so each side keeps redirecting the other
- A WordPress site address set to
http://while the server forceshttps:// - Conflicting rules in
.htaccess, a plugin and a CDN - A redirect rule whose pattern also matches its own destination
Don't redirect everything to the home page
When pages are deleted, it's tempting to send every old URL to the home page. Google's site move guidance warns against redirecting many old URLs to one irrelevant destination such as the home page, because it confuses users and may be treated as a soft 404. Redirect to the closest relevant page, or let a page that has no replacement return a 404 or 410. Our explainer on soft 404 errors covers this in more depth.
Checking your redirects
Our free redirect checker tests the four versions of your domain (http, https, www and non-www) hop by hop. It reports whether they all end on one URL, whether HTTP goes to HTTPS, whether any chain takes more than two hops, whether any temporary (302, 303 or 307) redirects are in use, and whether there's a loop. You need a free account to run it. To find internal links still pointing at redirected or missing pages, use the broken link checker, or run a free website audit for the full picture.
Frequently asked questions
Is a 301 or 302 better for SEO?
Neither is "better" in general; they mean different things. Use a 301 for permanent moves so Google indexes the new URL, and a 302 only when the original URL will come back.
Do 302 redirects pass link equity?
Google doesn't describe 302s as losing ranking signals. The issue is that Google treats a 302 as a weak canonical signal, so the old URL may stay in search results instead of the new one.
What is the difference between 301 and 308?
Both are permanent and Google treats them the same way. A 308 guarantees the browser keeps the original request method and body, which matters for forms and APIs; for normal pages, a 301 is fine.
How long should I keep a 301 redirect?
Google recommends keeping redirects for as long as possible, and generally at least one year. Removing them early can break old links and bookmarks, so many sites keep them indefinitely.
How many redirects in a chain is too many?
Google's crawlers follow up to 10 hops, but you should aim for one. Each extra hop slows the page for visitors, so point every old URL directly at its final destination.
Sources
More guides for your industry
Free checklist (PDF)
Free e-commerce brands website checklist
30 practical checks for e-commerce brands: website speed and mobile, Google Business Profile and reviews, email security, booking and enquiry handling, and AI search visibility. Each one says why it matters, and many link to a free tool that checks it.
Written by the MakeItFlow team
We build the website audit these guides are based on. Every fact is checked against the primary sources listed above and this guide was last reviewed on 31 October 2026 . How we research and check
Check your own site in 30 seconds
Run a free audit covering speed, SEO, DNS, email authentication and security headers — and get a prioritised fix list.