301 vs. 302 – When Each Status Code Makes Sense

Nils Martens 10/12/2022

We reveal to you the difference between a 301 and a 302 redirect, how to set them up and which tools can help you.

Status codes serve for communication between client and server - questioner and respondent. There are numerous responses. 301 and 302 are two very common status codes. They are sent to the client by the server when there is a redirect from the originally visited URL or domain to another URL or domain.

However, there is a significant difference between the two redirects, which we will discuss in this article. We will also show you how to set up, identify 301 and 302 redirects, and which 7 SEO software options reviewed on OMR can support you.

Important fact to start: redirects are very important for your SEO!

How redirects work and why they are important

If you are moving your website to a new domain or relaunching your site, a redirect from the previous URL makes sense. Especially because associated backlinks are preserved, as is the ranking of the ex-URL on Google and Co. It makes a big difference whether you delete the old URL and simply switch to a new one or redirect from the old one. If you delete the old domain, you delete everything. With the new domain, you will have to start your SEO from scratch. This is probably not what anyone wants, considering the difficult challenge of achieving a good ranking on Google.

To now inform requesting clients that a redirect is present, your server responds with the status codes 301 or 302. They are very similar in their meaning, but have a significant difference to show. We write this flatly because both are often equated and this can lead to errors – with consequences for SEO!

When you use a 301 redirect

Redirect 301 is titled "moved permanently". The English term expresses that the redirect is permanent, you thus have no intention of reactivating the old domain. The good news: The entire Link Juice of the previous domain is inherited by the new one!

Specifically, the 301-redirect is good for the following scenarios:

  • The website protocol changes = if you want to encrypt your site from now on with an SSL certificate and redirect from http to https.
  • Moving to a new domain = if for example your brand name changes or you switch from .de to .com for internationalization.
  • Avoid duplicate website = if you want to avoid Duplicate Content (Google doesn't like it at all) and want to redirect from https://www.domain.de to the www-free version - or vice versa.
  • Change of the URL structure = If you tinker with your website and the directories change as a result, you can make it easy for your users by redirecting.

The last point on the list also shows the greatest added value of a 301 redirect - aside from the SEO standpoint: You make it easy for your visitors to find pages, even if you have made changes!

How long should you keep a 301 redirect

Google doesn't provide any information on how long a 301 redirect has to be in place before it becomes superfluous and you can remove the redirect. It's best to pay attention to when your new domain has been completely indexed by Google and the old domain or URL is hardly crawled anymore. You can check both with SEO tools that you can find at the end of the article or directly on OMR Reviews.

When you use a 302 redirect

Some of you may have already figured it out: While the Status code 301 declares a permanent redirect, code 302 stands for a temporary redirect. The redirection to another URL or domain thus takes place within a certain period.

This is mostly used for online shops, when products are only sold seasonally or when you want to redirect to time-limited campaign URLs (like affiliate campaigns). In addition, 302 redirects are suitable for website tests and tracking. Before you consider a domain move, you can first test. If the starts look good, you can install a 301 redirect to complete the move.

With temporary 302 redirects, the Pagerank is also transferred, but the target URLs or domains are not indexed by Google. You should therefore only use such redirects temporarily.

How to set up a redirect

Important tip before you start setting up: Always make a backup first before you change a code. Even the slightest mistake can have uncomfortable consequences.

How you proceed depends on whether you are using an Apache Web server (is also the way for WordPress websites) or want to set up the Redirect via PHP. We'll show both ways!

Redirect via Apache web server

You can use the following instructions for 301 and 302 redirects alike:

  1. Log in via FTP on your web server.
  2. Open the .htaccess file (the file may be hidden. You can unhide hidden files via the menu item usually named 'Display').
  3. Add "redirect /url-old-page https://your-domain.com/url-new-page" at the top of the code.

How you need to edit the code snippet: "url-old-page" is the URL starting point from which to redirect to the new URL, labeled in the example code as "https://your-domain.com/url-new-page". So fist, you enter the old URL (without writing anything else before it), then the new URL. Done!

If you want to move an entire domain, follow steps one and two just as well. Step three requires a longer code snippet in this case:

RewriteEngine On

RewriteBase /

RewriteCond %{HTTP_HOST} !old-domain.com$ [NC]

RewriteRule ^(.*)$ http://www.new-domain.com/$1 [L,R=301]

Under "old-domain.com" you add your previous address and under "new-domain.com" the new address (with "http://www." or "https://www.").

WordPress plugins likeRank Math or other plugins can also assist you in setting up redirects. Check this out before tinkering with a file like .htaccess.

Redirect via PHP

If the source script is a PHP file, proceed as follows:

  1. Open the PHP script that should be redirected.
  2. Insert the following source code in line one:

    ⁠<?php header("HTTP/1.1 301 Moved Permanently"); header("Location: https://www.your-domain.com/new-url.php"); header("Connection: close"); ?>

Simply adjust the name under "new-url.php" of the new source to which you want to redirect. Et voilà, the PHP redirect is complete!

How to identify or verify a redirect

To check whether a redirect is active for your website, you can use SEO software likeRyte,WildShark SEO Spider orsearchVIU, which show the number of URLs affected by each status code. Small tip: Keep an eye especially on 4xx and 5xx codes. These indicate client errors or server errors.

Regularly checking all your URLs is necessary to create a good user experience and increasingly satisfy Google. With SEO tools, therefore, always check your 301 redirects, as well as the other status codes.

7 software that can help with 301 and 302 redirects

There are several SEO software solutions. We have brought you the 7 best solutions that are suitable for checking status codes and crawling. By clicking on the respective tools, you will get to OMR Reviews. There all seven SEO software solutions are rated by verified users and here and there supplemented with a live report. This way, you can easily compare and pick out the best software solution:

seo-tool-screenshot.png

Screaming Frog SEO Spider is one of many SEO tools that can identify and set up 301 and 302 redirects.

Nils Martens
Author
Nils Martens

Verfolgt die Software-Welt schon seit Windows 3.1 – als Slack, Google Meets und Ahrefs noch nicht existierten. Für OMR Reviews ist Nils als Redakteur mit Hype auf Technik, Internetkultur und Software unterwegs. Außerdem kümmert er sich als Freelancer um die Content Creation & das Personal Branding von CEOs auf LinkedIn. In seiner Freizeit findet ihr ihn gerne mal beim FPS-Zocken.

All Articles of Nils Martens

Software mentioned in the article

Product categories mentioned in the article

Join the OMR Reviews community to not miss any news and specials around the software seeking landscape.