301 vs. 302 Redirects for search engine optimization: Which Ought to You Use?

0

Redirects are simple. If you’re moving content to a new location permanently, use a 301 redirect. If you’re moving it temporarily, use a 302 redirect.

But you might be wondering, why does this even matter? After all, users can’t tell the difference between 301s and 302s. Both are identical in their functionality.

The answer is simple: Search engines view 301 redirects and 302 redirects differently. And choosing the wrong one can cause SEO issues that often go unnoticed for months or even years.

In this post, you’ll learn:

When to use 301 redirects

Here are a few common use cases:

  • You permanently change the URL of a web page.
  • You permanently migrate to a new domain.
  • You switch from HTTP to HTTPS.
  • You want to fix non-www/www duplicate content issues.
  • You permanently merge two or more pages or websites.
  • You permanently change the URL structure of your website.

When to use 302 redirects

Use cases for 302 redirects are few and far between, but there are some:

  • You want to redirect users to the right version of the site for them (based on location/language).
  • You want to A/B split-test the functionality or design of a web page.
  • You want to get feedback about a new page without affecting rankings for the old one.
  • You’re running a promotion and want to temporarily redirect visitors to a sales page.

There are undoubtedly other use cases, but they tend to be very specific and individual. The golden rule is that you should only use 302 redirects if you plan to bring back the old page after a short period.

You can create 301 and 302 redirects in several ways, but the most common method is to edit a website’s .htaccess file. You’ll find this file in your website’s root directory.

Sidenote.

If you don’t see this file in your site’s root directory, either your server isn’t running on Apache or you don’t have this file. You can check the kind of server you’re running with this tool. If it’s Apache, the solution is to create a .htaccess file using Notepad or TextEdit and upload it to your root server. If you’re running Nginx, read this. If you’re running Windows/IIS, read this.

If you’re using WordPress, a less daunting option is to use a free SEO plugin to create redirects. RankMath has this functionality built-in, but this plugin will also do the job.

How to create a 301 redirect

If you want to create a 301 redirect from one URL to another, add this to your .htaccess file:

Redirect 301 /old-page.html /new-page.html

You can also do this using RankMath or the Redirections plugin. Just choose the type of redirect you want, then add your source and destination URLs.

2 301 rankmath

If you’re looking to redirect the entire website, add this to your .htaccess file:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldsite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.oldsite.com [NC]
RewriteRule ^(.*)$ https://newsite.com/$1 [L,R=301,NC]

Just know that you’ll need to keep your old hosting active to redirect your site with .htaccess, which can be expensive. So it’s usually better to redirect through DNS. Most registrars allow you to select either a 301 or 302 redirect for this. If you’re using Google Domains, just hit Website > Forward domain, then enter the new domain and choose “Permanent redirect.”

3 google domains 301

You can learn how to create 301 redirects for more situations (e.g., non-www to www, HTTP to HTTPS) in our full guide to 301 redirects.

How to create a 302 redirect

If you want to create a 302 redirect from one URL to another, add this to your .htaccess file:

Redirect 302 /old-page.html /new-page.html

You can also do this with RankMath or the Redirections plugin in WordPress:

4 302 rankmath

If you’re looking to redirect the entire website, use this code:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldsite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.oldsite.com [NC]
RewriteRule ^(.*)$ https://newsite.com/$1 [L,R=302,NC]

Just know that you probably won’t want to use a 302 to redirect one site to another. Most domain changes are permanent, so you’ll want to use a 301. It’s the same story for redirects from HTTP to HTTPS, or from non-www to www (and vice-versa).

How Google treats 301 redirects vs. 302 redirects

As the functionality of 301 and 302 redirects are identical to the end-user, choosing which one to use comes mostly down to how Google treats them. And there are two things we need to talk about here:

  1. Indexation
  2. Link signals

Indexation

When one URL redirects to another, Google keeps only one of those URLs indexed.

For 301 redirects…

… that will be the ‘new’ URL. For example, if you create a 301 redirect from old-page.html to new-page.html, Google will index new-page.html and de-index old-page.html. That’s because the 301 redirect tells Google that this is a permanent move, so there’s no point keeping the old URL indexed.

People sometimes get confused about this because after creating a 301 redirect, the old URL can still show up for a while in Google when using site: searches.

For example, Moz changed and redirected their domain from seomoz.org to moz.com many years ago, but seomoz.org still shows up in Google.

5 301 site search

The reason for this is that, as Patrick recently explained, site: searches don’t tell you if a URL is indexed. For that, you need to use either the URL Inspection tool or Coverage report in Google Search Console.

For 302 redirects…

… the URL that Google indexes will usually be the original one. However, because Google knows people often mistakenly use 302s for permanent redirects, they actually assess each 302 redirect individually to try to determine what you really meant.

Here’s what Google’s John Mueller said:

When we recognize a redirect and we see it’s a 302, we assume it is a temporary redirect first and we assume you want the initial URL indexed, not the redirected target. […] However, when we recognize it is actually more like a permanent redirect and the 302 is maybe something that you accidentally set up, then we do treat that as a 301. And we say, instead of indexing the redirected URL, we’ll index the redirection target instead.

John Mueller

Nobody knows precisely how long a 302 redirect needs to be in place before Google begins treating it as a permanent redirect. Usually, it’s a few weeks to a few months, but it can be days, weeks, or months.

In some circumstances, Google even appears to treat 302s as 301s from the get-go.

For example, Patrick recently ran a small experiment where he implemented a 302 redirect from one established site to another. As soon as Google crawled the ‘old’ domain and saw the redirect, the ‘old’ domain disappeared from the search results in favor of the ‘new’ domain.

If you’re not sure how Google is treating your 302 redirects, here’s a quick ‘trick’:

Paste the redirecting URL into the Search Console’s URL Inspection tool. If it shows the “URL is not on Google” warning, Google must be treating the redirect as permanent (301). If it is on Google, then they’re treating it as temporary (302).

6 url is not on google

Just make sure to check the last crawl date when doing this. If this date comes after you implemented the redirect, request re-indexing and come back later.

Sidenote.

From our observations, Google is usually quicker to treat 302 redirects as permanent when redirecting to an ‘established’ page or site. That’s probably because the ‘new’ page or website has been around a while, so there’s a higher than average probability that you wanted to redirect the URL permanently.

Link signals

3XX redirects used to dilute PageRank, but that stopped in 2016.

30x redirects don’t lose PageRank anymore.— Gary 鯨理/경리 Illyes (@methode) July 26, 2016

Now, when you redirect one URL to another, link signals consolidate at one URL without dilution. However, the way this works is commonly misunderstood, as the type of redirect can impact where the signals consolidate.

For 301 redirects…

… link signals consolidate ‘forward’ to the ‘new’ URL.

For example, if old-page.html has ten backlinks, and you redirect (301) that to new-page.html, all link signals will consolidate at the new-page.html. In other words, Google should rank new-page.html as though it has ten links.

However, it’s not quite that simple because Google treats irrelevant redirects as soft 404s:

https://www.youtube.com/watch?v=nIDZmac_rMI&feature=youtu.be&t=76&ab_channel=GoogleWebmasters

That isn’t a problem if you’re moving content to a new URL without drastically changing it. But if the redirect is irrelevant, as is the case when redirecting an old blog post to your homepage, links to the ‘old’ page probably won’t help the ‘new’ page rank. So the golden rule is to keep your redirects as relevant as possible.

If you’re curious how Google is treating one of your 301 redirects, try this:

Go to Search Console > Links > External Links.

7 top linked pages

Next, filter the report by “Target page,” and paste in the ‘new’ URL. For example, we recently 301 redirected an old blog post (ahrefs.com/blog/seo-secrets/) to our blog homepage (ahrefs.com/blog/), so we’ll paste in the blog homepage and select the URL from the list.

top target pages new url

Next, paste the ‘old’ URL into Ahrefs’ Site Explorer and go to the Referring Domains report.

8 referring domains ahrefs

Finally, in GSC, filter the links by “Site,” and paste in referring domains from Ahrefs one by one.

If you do this for several referring domains and get no matches in GSC, Google is likely treating the redirect as a soft 404, and not counting the backlinks towards the ‘new’ URL.

9 no results domain gsc

If there is a match, click on the site to see the actual links. You should see something like this:

10 target url if different

Notice that the “Target URL (if different)” column shows the ‘old’ redirected URL. This tells us that Google is counting links to the redirected URL towards the ‘new’ URL.

For 302 redirects…

… link signals usually consolidate ‘backward’ to the ‘old’ URL.

For example, if you redirect (302) old-page.html to new-page.html, and new-page.html has ten backlinks, all link signals will usually consolidate at old-page.html. In other words, Google should rank old-page.html as though it has ten links.

However, things aren’t quite that simple. It depends on how Google treats the 302 redirect.

If they’re treating it as a temporary redirect, link signals will indeed consolidate backward. That’s assuming the redirected page is the same as or similar to the ‘new’ page. If not, they may treat it as a soft 404.

If they’re treating it as a permanent redirect, link signals will consolidate forward.

You can check how Google is treating a redirect with the URL Inspection tool. Just paste in the ‘old’ redirected URL. If the “Google-selected canonical” shows “Inspected URL” (as is the case below), Google is treating the redirect as temporary. If not, it’s treating it as permanent.

Should you ‘fix’ accidental 302 redirects?

Let’s say that you’ve made the common mistake of using 302 redirects for permanent moves. Do you need to spend precious time swapping them all to 301 redirects?

The answer depends on how Google currently treats those redirects.

If they’ve figured things out for themselves and are already treating the ‘accidental’ 302s as permanent moves, then changing them to 301s may not impact anything. If they haven’t yet figured things out, swapping the redirects from 302s to 301s is likely the best course of action.

You can use the URL Inspection tool in GSC to check how Google treats individual URLs, as shown in the previous section. However, that’s pretty time-consuming if you have a lot of redirects. A faster method is to first look for 302 redirects that get organic traffic. After all, that’s a telltale sign that Google is still treating the redirect as temporary.

You can do this in Ahrefs’ Site Audit. Just crawl your site, then check the Redirects report for the “302 redirects” warning.

12 302 redirects site audit

If it’s there, click to view the affected URLs, and sort the report by “Organic traffic” from high to low.

13 302 redirects with traffic

Because this data is an estimate from Ahrefs’ Site Explorer, it’s worth double-checking any redirected URLs with traffic in the URL Inspection tool. If the user-declared and Google-declared canonicals match, Google is treating the 302 redirect as permanent. If they don’t, the redirected page is likely getting organic traffic because it’s still indexed and Google is treating it as temporary. That isn’t desirable if you used a 302 redirect by accident for a permanent move. Luckily, swapping the 302 redirect to a 301 should fix the issue.

Final thoughts

Redirects aren’t that complicated. If you’re moving content to a new location permanently, use a 301 redirect. If you’re moving it temporarily, use a 302 redirect.

That said, it might be reassuring to know that even if you do happen to use the wrong type of redirect, Google will likely figure out what you meant eventually. Does this always happen? Of course not. Google isn’t always smart enough to figure out what you meant without fail every time, so it’s best practice to use the correct type of redirect where possible.

Got questions? Ping me on Twitter.

Leave A Reply

Your email address will not be published.