Get 302 ошибка

302 Found: What It Is and How to Fix It

May 20, 2022 12:57:21 PM |
302 Found: What It Is and How to Fix It

A close look at what a 302 Found response code is, including troubleshooting tips to help you resolve this error in your own application.

A 302 Found message is an HTTP response status code indicating that the requested resource has been temporarily moved to a different URI. Since the location or current redirection directive might be changed, a client that receives a 302 Found response code should continue to use the original URI for future requests. But what about an unexpected 302 Found Status Code? 

This article will examine the 302 Found status error and look at a few troubleshooting tips and potential fixes.

The Problem is Server-Side

All HTTP response status codes in the 3xx category are redirection messages. These codes tell the user agent (i.e., your web browser) that additional action is required to complete the request.

Unlike client error responses found in the 4xx codes, like the 404 Not Found Error, which can stem from either a client- or server-side issue, a 302 Found code means there’s an issue on the actual web server hosting your application.

Since the 302 Found indicates something has gone wrong within your application’s server, we can disregard the client-side. If you’re trying to diagnose a 302 error, ignore most client-side code and components, such as HTML, cascading style sheets (CSS), client-side JavaScript, etc. Instead, it will be something on the server-side, performing most of the logic and processing behind the scenes.

That said, the appearance of a 302 Found is usually not something that requires much user intervention. All modern browsers will automatically detect a 302 error response code. Once detected, it will process the temporary redirect action automatically. 

Here’s what it looks like broken down: The web server hosting the application usually includes a special Location header as part of the response it sends to the client. This Location header indicates the new URL where the client can find the requested resource.

For example, if a request comes in to access the URL https://airbrake.io, but the web server is configured to force redirection to a secure version using https, the server response will include the Location: https://airbrake.io header. This tells the browser that it should redirect this single request to https://airbrake.io. 

In most cases, the browser will automatically detect this 302 Found response code, read the new Location URL, and redirect the request to that new location.

If your application generates unexpected 302 Found response codes, try the following methods to diagnose the problem.

Start With a Thorough Application Backup

Before diagnosing an error, you should perform a complete backup of your application, database, etc. Even better, create a full copy of the application onto a secondary staging server that isn’t available to the public. This will give you a clean testing ground to test all potential fixes.

Diagnosing a 302 Found Response Code

An HTTP 302 Found code means that the client should request the resource temporarily at a different URI. However, the server could be misconfigured. Misconfiguration can improperly respond with 302 Found codes instead of the standard and expected 200 OK code. 

A large part of diagnosing the issue will be double-checking what resources/URLs are generating 302 Found response codes. From there, you’ll want to determine if these codes are appropriate or not. We’ll go over some troubleshooting tips and tricks to help you try to resolve this issue.

Troubleshooting on the Server-Side

Here are some additional tips to help you troubleshoot what might be causing the 302 Found to appear.

Confirm Your Server Configuration

Your application is likely running on a server using one of these three popular webserver software: Apache, nginx, or Cloudflare server. At the time of publication, these web servers make up over 86% of the world’s web server software! 

First things first, check the configuration files for your web server software for unintentional redirect instructions. 

Find which web server your application uses by looking for a key file. From there, follow the steps noted below depending on your server. To keep this article a bit shorter, we’ll only focus on Apache and nginx, as they are the most popular. 

Apache

If your web server is Apache then look for a .htaccess file within the root directory of your website file system. 

For example, if your application is on a shared host, you’ll likely have a username associated with the hosting account. In such a case, the application root directory is typically found at the path of: /home/<username>/public_html/, so the .htaccess file would be at /home/<username>/public_html/.htaccess.

Locate the .htaccess file and open it in a text editor. Once opened, look for lines that use RewriteXXX directives, which are part of the mod rewrite module in Apache. Covering exactly how these rules work is well beyond the scope of this article. But, here’s the basic concept: a RewriteCond directive defines a text-based pattern that is matched against entered URLs. Suppose a visitor requests a matching URL to the site. In that case, the RewriteRule directive that follows one or more RewriteCond directives is used to perform the actual redirection of the request to the appropriate URL.

Here is a simple RewriteCond and RewriteRule combination that matches all incoming requests to example.com and establishes a temporarily redirection to that same URI on the temporary-example.com domain instead:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^example\.com$

RewriteRule ^(.*)$ http://www.temporary-example.com/$1 [R=302]

Notice the extra flag at the end of the RewriteRule, which explicitly states that the response code should be 302. This tells the user agents (browsers) that this is a temporary redirect. If you find any strange RewriteCond or RewriteRule directives in the .htaccess file that don’t seem to belong, try temporarily commenting them out (using the # character prefix) and restarting your webserver to see if this resolves the issue.

nginx

If your server is running on nginx, you’ll need to look for a completely different configuration file. By default this file is named nginx.conf and is located in one of a few common directories: /usr/local/nginx/conf, /etc/nginx, or /usr/local/etc/nginx. 

Once located, open nginx.conf in a text editor and look for rewrite directives using the redirect flag. For example, here is a simple block directive (i.e. a named set of directives) that configures a virtual server by creating a temporary redirection from example.com to the temporary-example.com:

server {

    listen 80;

    listen 443 ssl;

    server_name www.example.com;

    rewrite ^/$ http://www.temporary-example.com redirect;

}

Rewrite directives in nginx are similar to the RewriteCond and RewriteRule directives found in Apache, but they tend to contain more complex text-based patterns for searching. Look through your nginx.conf file for any abnormal rewrite directives that include the redirectflag (the alternative permanent flag will issue 301 response codes instead). Comment out any abnormalities and restart the server. If the unexepcted 302 code still exists, continue on to the next method.

Check for Outdated Software

The RFC specification document for HTTP 1.0 states that a 302 Found Response code indicates the client should perform a temporary redirection. 

However, many newer browsers process a 302 code received as an erroneous GET request via a POST request. This can confuse the webserver. The HTTP 1.1 RFC specification document added the 303 See Otherand 307 Temporary Redirect response codes, which are explicit means of handling POST-to-GET and temporary direct responses.

Scour the Logs

Nearly every web application will keep some form of server-side logs. 

Application logs are typically the history of what the application did, including requested pages, connected servers, database results, etc. 

Server logs are related to the actual hardware running the application. They will often provide details about the health and status of all connected services, or even just the server itself. Google “logs [PLATFORM_NAME]” if you’re using a CMS, or “logs [PROGRAMMING_LANGUAGE]” and “logs [OPERATING_SYSTEM]” if you’re running a custom application, to get more information on finding the logs in question.

Once you have access to the logs, try to find any weird redirecting. They could give you important context information you can then use to debug your application.

Debug Your Application Code

If all else fails, it may be that a problem in some custom code within your application. 

Make a copy of the entire application to a local development machine and perform a step-by-step debug process. This will allow you to recreate the exact scenario in which the 302 Found occurred and view the application code at the moment something went wrong. 

No matter the cause, the appearance of an unexpected 302 Found within your web application might mean you need an error monitor.

Real-Time Error Alerts

When a critical error occurs within your application, you want to know. Airbrake Error and Performance Monitoring alerts you and your team immediately when an error occurs. Whether it’s a new occurrence or a latent error suddenly popping up, Airbrake will tell you where the error occurred, right down to the line of broken code. 

Airbrake’s error monitoring software provides real-time error monitoring and automatic exception reporting for all your development projects. Plus, no matter what you’re working on, Airbrake easily integrates within your current workflow and works with popular languages and frameworks, such as JavaScript, Python, Ruby, and more. Create a free Airbrake dev account today and see why so many of the world’s best engineering teams use Airbrake to revolutionize their exception handling practices.

Note: We published this post in November 2017 and recently updated it in May 2022.

Whenever we get a HTTP 302 error, it requires a redirect and the same questions usually arise:

Here are some of the questions:

  1. Is my website ready for it?
  2. What type of redirection is the most appropriate for my case?
  3. Will I lose all the SEO work I’ve done so far?
  4. Will Google penalize me? What happens if I eliminate redirects?
  5. How are they made?
  6. How do I fix error 302? (if it occurs)


In this article, I will answer all these questions so that you have more clarity to proceed in each case.

What is 302 redirect?

Code 302 indicates a temporary redirection.
One of the most notable features that differentiate it from a 301 redirect is that, in the case of 302 redirects, the strength of the SEO is not transferred to a new URL.

google seo

This is because this redirection has been designed to be used when there is a need to redirect content to a page that will not be the definitive one.
Thus, once the redirection is eliminated, the original page will not have lost its positioning in the Google search engine.
Although it is not very common that we find ourselves in need of a 302 redirect, this option can be very useful in some cases. These are the most frequent cases:

  • When we realize that there is some inappropriate content on a page. While we solve the problem, we can redirect the user to another page that may be of interest.
  • In the event that an attack on our website requires the restoration of any of the pages, this redirect can help us minimize the incidence.

A redirect 302 is a code that tells visitors of a specific URL that the page has been moved temporarily, directing them directly to the new location.
In other words, redirect 302 is activated when Google robots or other search engines request to load a specific page. At that moment, thanks to this redirection, the server returns an automatic response indicating a new URL.
In this way errors and annoyances are avoided both to search engines and users, guaranteeing smooth navigation.

What is a redirect 302 for?

The redirect 302 serves, for example, to have several versions of a homepage in different languages.
The main one can be in English, but if the visitors come from other countries then this system automatically redirects them to a page in their language.

302 redirect

In this way, a mobilization of web traffic is achieved, but at the same time, the influence at the SEO level of the main page is not diluted. This continues to grow, even though there is no transfer of authority, as we explained earlier.

HTTP 302 redirect example

The most common HTTP 302 redirect example case is Google.
Regardless of the country from which you access, if you type in https://www.google.com/, you will be redirected to the Google version in the language/country that corresponds to you.

google search
In case of Germany, 302 automatically take us to https://www.google.de/ so that we can search for content in German.
Portals of successful companies such as Coca-Cola or even Fujitsu also use this system to redirect traffic to where they consider most convenient.

Here are some of the most common reasons for the 302 redirect error:

  • Using 302 redirects while the domain is moving;
  • Creating a 302 redirect when you move the document;
  • Using a 302 redirect during site protocol change;
  • Creating 302 redirects while site structure is changing.

HTML redirect 302 is not recommended when the method of the original request is to be applied to the request of the destination URL — for example, moving the URL of a form directive that uses the POST method for a specific period.
You should not use the status code 302 if you want to transfer SEO-weight to the destination URL.

How to identify HTTP 302 error?

Verifying that the 301 and 302 redirect settings are correct is very easy.
When entering into the address bar of the old address, we observe what is happening.
The change of address indicates that everything is fine with the redirect.
The address remains the same – you need to look for the source of the problem, but first, we advise you to clean the cache and try again.

domain name
There is another option – to apply for checking the server response code to online services, for example, http://example.com/e_redirect/.
If you set up a redirect correctly, after entering the domain name, you will see the response code 301 or 302. It depends on what kind of redirection you planned to receive initially.
Some services additionally display the code given by the server after the redirect, and here there is only one valid option – 200 OK.

How to fix HTTP 302 error?

Method 1: Check the server configuration

The application may run on the server that uses one of these two most common web server programs, Nginx or Apache. These two web servers account for more than 84 percent of the global web server program!
Therefore, the first step in determining the 302 response code is checking the mandatory redirect instructions in the webserver program configuration file.

For Apache web Server

Step 1: Open .htaccess file on the server

To identify the webserver, you need to find the key file. If you are using the Apache web server, locate the .htaccess file in your site’s root filesystem.

cPanel File Manager
If your program is on the shared host, you might have your username linked to the host account, for example. In this case, usually, the directory of application root is located in the path:
/home/<username>/public_html/path, thus the .htaccess file is located at /home/<username>/public_html/.htaccess.

Step 2: Find the mod_rewrite directives

Once you find .htaccess file, open it in text-editor and find the line that uses the RewriteXXX directives belonging to the Apache mod_rewrite module.

mod_rewrite
However, the core idea is that the RewriteCond directive outlines a text model that is compared to the registered URL. When a visitor requests the corresponding URL on a site, the RewriteRule directive which tracks one or multiple RewriteCond instructions will actually redirect the request toward the corresponding URL.
For instance, the following is an easy combination of RewriteRule and RewriteCond that satisfies all the requirements of example.com, but instead inserts a temporary redirect into the same URI in the temporary domain — example.com:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*)$ HTTP://www.temporary-example.com/$1 [R=302]

Notice the additional banner at the bottom of RewriteRule, which clearly illustrates that a response code has to be 302, showing to the browser agent that it is a temporary redirect.

Step 3: Reset the directives in .htaccess file
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

Therefore, if you get an unusual RewriteRule or RewriteCond directive in your .htaccess file that doesn’t seem to fit to it, try to temporarily annotate them (prefixed with #) and restart the webserver to check if the issue is resolved.

For Nginx web server

Step 1: Open the nginx.conf file

ngix configuration
If your web server is operating on Nginx, you should look for a totally different file of configuration. This file is specified as nginx.conf by default and found in one of the common directories listed below:

/usr/local/nginx/conf, /etc/nginx or, /usr/local/etc/nginx.

Step 2: Rewrite the directives on nginx.conf file

After detection, open the nginx.conf file in your text editor and find the rewrite directives that are relating to the redirect indicator.

HTTP 302 error: 301 scheme
For example, this is a plain block directive (declared a set of statements) that sets up the virtual server through generating a temporary redirect from abc.com to a temporary-abc.com:

server {
listen 80;
listen 443 ssl;
server_name www.abc.com;
rewrite ^/$ http://www.temporary-abc.com redirect;
}

Nginx rewrites directives are parallel to Apache RewriteRule and
RewriteCond because they usually comprise more complicated text-oriented search patterns.

Step 3: Check the replacement policy of nginx.conf file

In any case, check the nginx.conf file for the exception replacement policy that contains a redirect flag (other permanent flag return response code 301).

HTTP 302 error: nginx parameters
Please note any exceptions before you restart the server in order to check if the problem is resolved.

Method 2: Search for out-of-date software

The specification document of RFC for HTTP 1.0 states that the aim of a “302 Found” response code is intended to indicate that the client should execute a temporary redirect.

HTTP 302 error: device risk
However, many new browsers will process the code 302 received through the POST request as an invalid GET request.
This has triggered snags and confusion with particular web server programs that attempt to force the browser to perform the right work when it needs to be redirected temporarily.
To solve this problem, the RFC HTTP 1.1 specification document returned 303 response codes, another 307 temporary redirects, which is an understandable way to manage POST-to-GET or temporary, transient responses.

Method 3: Cleaning the Logs

Almost all web applications store records on the server. The application log usually represents the application history, like which pages, servers were requested and connected, which were obtained from the provided database, and so on.

HTTP 302 error: clean the logs
The server logs are connected to the current device that runs the programs and usually contains information about the status and health of all the connected services, and even the information about the server.
Google record [PLATFORM_NAME] in the CMS or use [PROGRAMMING_LANGUAGE] to register and register [OPERATING_SYSTEM] when launching the custom application for more information to get these records.

Method 4: Fix the application code

In the case, all the above-discussed methods fail, the problem may be in the user code of the application that caused the problem.

HTTP 302 error: web browser
Try to determine the cause of the problem by manually locating the application and analyzing it in the server and application log files.
It’s a good idea to copy the full application to your local development computer and step through it to see exactly what happens to the 302 scans and see the code for each application.

HTTP 302 Error: Conclusion

Finally, as you have seen, we do not have to fear a lot about the HTTP 302 redirect errors. Without going any further, they are a fantastic way to avoid losing traffic on our web pages with the inevitable changes that arise over the years.
I hope that, after reading this article, you will not get chills every time about how do I fix the 302 moved temporarily error.
Whether you want to make a contribution to the post or if you have a question or just want to give your opinion, do not hesitate to comment below!

HTTP 302 codes are a valuable way to redirect website users to a different URL temporarily. However, if your website is delivering 302 redirects in error, it’s a sign that something’s wrong.

Don’t worry — you can fix this problem — but you’ll need to do some troubleshooting.

The first step is to understand precisely what HTTP 302 codes are, how they work, and why they occur. Once you know that, you can figure out what’s gone wrong and how to make it right.

In this post, we’ll tell you everything you need to know about HTTP 302 errors. Then we’ll share five troubleshooting tips to help you fix them.

Let’s get started!

Check Out Our Video Guide to The 302 HTTP Status Code

What Are HTTP 302 Status Codes?

302 codes are a specific type of HTTP status code. These codes are like “notes” that a server delivers to your browser.

Whenever you click on a link or navigate to a URL, your browser requests the webserver for the same. In return, the server sends back the relevant resource (e.g. the page you’re trying to access) along with an HTTP header. The HTTP status codes are inside that header.

Typically, you can’t see these status codes anywhere on the web page. You’ll only usually see them when an error occurs, or if you’ve installed a browser extension that makes them visible:

A screenshot showing the current URL's HTTP status code, displayed through use of a Chrome browser extension.

A web page’s HTTP status code, shown using a Chrome browser extension.

3xx status codes (301, 302, etc.) are a class of status codes called “redirection codes.” They’re returned whenever the server sends back a new resource instead of the requested resource.

In other words, they’re shown when the website page you intended to access redirects you to a different page.

The critical difference between code 301 and code 302 is that the former is used for permanent redirects, whereas the latter is for temporary redirects.

The 301 redirects also pass “link juice,” whereas 302s don’t. That has a significant impact on Search Engine Optimization (SEO).

Uh oh… you’ve just seen an HTTP 302 code pop up. 😬 Now what? 🤷‍♀️ Start with this thorough guide ⤵Click to Tweet

How 302 Redirects Work

When you set up a 302 redirect for a page on your website that’s temporarily unavailable, and a user visits that page, your webserver will respond to the visitor’s browser with a special Location header. This header will indicate the new URL that the browser should redirect the user to instead.

For example, imagine that a user types blog.example.com into their browser URL bar, but the website is configured to redirect it to blogging.example.com.

The server response will include both the 302 status code and the Location: blogging.example.com header. This setting tells the user’s browser to redirect this request to the new URL instead.

Of course, all of this happens automatically and behind the scenes. The user shouldn’t be able to see any of this play out. Instead, their browser should automatically take them to the new resource.

Why HTTP 302 Errors Happen

If something is misconfigured on your website, it might cause 302 codes to be issued in error. If this happens, you may run into problems such as:

  • A page on your website that redirects your visitors elsewhere when it shouldn’t
  • A page on your website that redirects your visitors to the wrong resource
  • The ERR_TOO_MANY_REDIRECTS error (also known as a “redirect loop”)

The last of these issues is the only one that will display an actual error page. If you’re using the Chrome browser, a redirect loop error page will look something like this:

The Chrome ERR_TOO_MANY_REDIRECTS error message, with the text

The Chrome ERR_TOO_MANY_REDIRECTS error message.

On Mozilla Firefox, it looks like this:

The Firefox ERR_TOO_MANY_REDIRECTS error message, with the text

The Firefox ERR_TOO_MANY_REDIRECTS error message.

All of the above problems are caused by some misconfiguration. It may be a plugin conflict, incorrect URL settings, or a misconfigured .htaccess file.

How to Fix the HTTP 302 Error (5 Methods)

Next, we’ll walk you through five troubleshooting methods that can help you figure out what’s causing the problem and fix it.

Before we get started, make sure to perform a complete backup of your website first. That way, if anything goes wrong, you can always revert to the previous version. You can use a WordPress plugin to do this.

1. Determine Whether the Redirects Are Valid

302 responses are usually not errors. Temporarily redirecting users to a different page can be a valid configuration and isn’t usually something that requires fixing.

It’s only an error if your website is responding with 302 codes that it shouldn’t be issuing, or if it’s causing a redirect loop. Therefore, the first step is to double-check which URLs are generating the HTTP 302 codes and determine whether the redirect is appropriate or not.

To do so, you can navigate to the pages on your website you suspect of issuing the 302 error and see for yourself if they behave as expected. If a temporarily unavailable page redirects to the correct resource, it’s appropriately configured.

However, if a page redirects you to the wrong resource or your browser reports a redirect loop by bringing up an ERR_TOO_MANY_REDIRECTS error page, it’s a sign that one (or more) of your redirects isn’t configured quite right.

2. Check Your Plugins

One of the most common causes of 302 errors and redirect loops is plugins.

Some WordPress redirect manager plugins and SEO tools like Yoast SEO manage your website redirects for you and enable you to set up redirect rules:

The Yoast SEO Premium plugin redirect settings page.

The Yoast SEO Premium plugin redirect settings page.

If these rules are misconfigured, or if two plugins conflict, it can cause unexpected issues. Therefore, you’ll need to check each relevant tool that’s installed on your site.

For example, if you’re using the popular 301 Redirects WordPress plugin, you can check the configuration by navigating to Settings > 301 Redirects. Under Redirect Rules, you’ll see a list of all the redirect rules you’ve set up:

The Redirect Rules settings page for the 301 Redirects WordPress plugin.

The Redirect Rules settings page for the 301 Redirects WordPress plugin.

Check all the 302 redirects listed here, and make sure they’re all correct.

You’ll also want to ensure that you haven’t set up anything in a way that could cause a redirect loop. For example, if Page-A is set to redirect to Page-B, but Page-B is also set to redirect to Page-A, this will cause an error.

If you have multiple redirect manager plugins and you’re not sure which one is causing the issue, you can try deactivating them one by one from the WordPress Plugins page (be sure to make a backup first):

The Plugins page in the WordPress admin dashboard.

The Plugins page in the WordPress admin dashboard.

After deactivating each plugin, try revisiting the problem URL to see if the 302 error persists.

If the problem is suddenly fixed, you’ll know which plugin was causing the issue, and you can then choose to troubleshoot further or remove it from your site.

3. Ensure That Your WordPress URL Settings Are Configured Correctly

Another common cause of the HTTP 302 error is a misconfiguration in the WordPress URL settings.

To check this, navigate to Settings > General in your WordPress dashboard. Here, you should see a WordPress Address (URL) field and a Site Address (URL) field:

The General Settings page in WordPress with highlighted Address fields.

The General Settings page in WordPress.

In most cases, the URLs in both of these fields should match. Make sure they’re both the same, including the “www” portion (or lack thereof) before the domain name.

If they don’t match, update the settings, then check the URL of the page issuing the HTTP 302 error to see if it’s fixed.

4. Check Your Server Configuration

A misconfigured server can also sometimes cause 302 redirect errors. Therefore, the next step is to check your server configuration.

If your host uses the Apache webserver, you can do this by checking your.htaccess file.

First, connect to your site’s server via a control dashboard like cPanel or an FTP client. Then navigate to the root directory of your site — the same place as the wp-admin and wp-content folders — and find the .htaccess file:

A screenshot of an .htaccess file highlighted in a website's root directory folder.

The .htaccess file in the site’s root.

If you aren’t finding the .htaccess file here (and you’re sure on an Apache server), you may need to tell FileZilla to show hidden files before it’ll appear in the file list.

Next, open the file in your favorite text editor. It should look something like this:

A screenshot of an .htaccess file open in a text editor, with RewriteXXX directives highlighted within the code.

RewriteXXX directives in an .htaccess file.

Now, we’re going to look for RewriteXXX directives (the highlighted elements above). Without getting too technical, RewriteCond and RewriteRule directives are used to perform redirections from one URL to another.

The RewriteCond directive specifies the URL you want to redirect the visitor away from, while the RewriteRule directive specifies the URL you want to redirect them to. Here’s an example:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^website.com$
RewriteRule ^(.*)$ http://www.temporary-website.com/$1 [R=302]

The flag at the end, “[R=302]”, tells the browser that this is a temporary 302 redirect.

If you notice any RewriteXXX combinations similar to the above in your .htaccess file that shouldn’t be there, you can comment them out, save the changes, and reload the problem web page to see if it resolves the issue.

Just make sure to download and save a spare copy of your .htaccess file before you make any changes in case something goes wrong.

5. Speak to Your Web Host

If you’ve tried all of the above methods and you’re still having trouble, the next step is to speak to your web host.

Troubleshooting a 302 code error beyond this point requires a lot of technical know-how. Therefore, unless you’re a professional developer, it’s probably best to get help from an expert.

At Kinsta, we take support seriously. Our team of experts is always on-hand to help you resolve issues like this whenever they arise:

Screenshot of the Kinsta Support page.

The Kinsta Support page.

We’re available 24/7. All you have to do is log in to your MyKinsta account and contact us via live chat to connect with a support engineer who can help in real-time.

Don’t let HTTP 302 codes slow your roll. 🙅‍♀️ Learn how to resolve them with these 5 troubleshooting tips 💥Click to Tweet

Summary

HTTP 302 status codes are a completely normal way to redirect your website visitors. However, they should only be used when the resource page is temporarily unavailable.

Suppose your website is issuing 302 codes in error or causing redirect loops. In that case, it’s vital to fix this problem as soon as possible, or it may negatively impact your SEO and conversions.

You can follow these five steps to fix HTTP 302 errors on your website:

  1. Determine whether the redirects are appropriate or not by examining the URLs that are issuing the 302 redirects.
  2. Check your plugins to make sure any redirect settings are valid.
  3. Ensure that your WordPress URL settings are configured correctly.
  4. Check your server configuration by looking for incorrect RewriteXXX directives in your .htaccess file (Apache servers only).
  5. Speak to your web host for further technical support if the problem persists.

Do you have any questions left about the HTTP 302 error? Let us know in the comments section.

Kinsta company logo

Jeremy Holcombe

Content & Marketing Editor at Kinsta, WordPress Web Developer, and Content Writer. Outside of all things WordPress, I enjoy the beach, golf, and movies. I also have tall people problems ;).

  • Website

  • LinkedIn

From Wikipedia, the free encyclopedia

The HTTP response status code 302 Found is a common way of performing URL redirection. The HTTP/1.0 specification (RFC 1945) initially defined this code, and gave it the description phrase «Moved Temporarily» rather than «Found».

An HTTP response with this status code will additionally provide a URL in the header field Location. This is an invitation to the user agent (e.g. a web browser) to make a second, otherwise identical, request to the new URL specified in the location field. The end result is a redirection to the new URL.

Many web browsers implemented this code in a manner that violated this standard, changing the request type of the new request to GET, regardless of the type employed in the original request (e.g. POST).[1] For this reason, HTTP/1.1 (RFC 2616) added the new status codes 303 and 307 to disambiguate between the two behaviours, with 303 mandating the change of request type to GET, and 307 preserving the request type as originally sent. Despite the greater clarity provided by this disambiguation, the 302 code is still employed in web frameworks to preserve compatibility with browsers that do not implement the HTTP/1.1 specification.[2]

As a consequence, RFC 7231 (the update of RFC 2616) changes the definition to allow user agents to rewrite POST to GET.[3]

Example[edit]

Client request:

GET /index.html HTTP/1.1
Host: www.example.com

Server response:

HTTP/1.1 302 Found
Location: http://www.iana.org/domains/example/

See also[edit]

  • List of HTTP status codes
  • HTTP 301

References[edit]

  1. ^ Lawrence, Eric. «HTTP Methods and Redirect Status Codes». EricLaw’s IEInternals blog. Retrieved 2011-08-20.
  2. ^ «Request and response objects | Django documentation | Django». Docs.djangoproject.com. Retrieved 2014-06-23.
  3. ^ «Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content». Tools.ietf.org. Retrieved 2019-01-05.

External links[edit]

  • RFC 7230, RFC 7231, RFC 7232, RFC 7233, RFC 7234, RFC 7235 (HTTP 1.1)
  • RFC 2616 (HTTP 1.1) (obsolete)
  • RFC 1945 (HTTP 1.0)

This question was asked a long ago, while the RFC 2616 was still hanging around. Some answers to this question are based in such document, which is no longer relevant nowadays. Quoting Mark Nottingham who, at the time of writing, co-chairs the IETF HTTP and QUIC Working Groups:

Don’t use RFC2616. Delete it from your hard drives, bookmarks, and burn (or responsibly recycle) any copies that are printed out.

The old RFC 2616 has been supplanted by the following documents that, together, define the HTTP/1.1 protocol:

  • RFC 7230: Message Syntax and Routing
  • RFC 7231: Semantics and Content
  • RFC 7232: Conditional Requests
  • RFC 7233: Range Requests
  • RFC 7234: Caching
  • RFC 7235: Authentication

And, as of June 2022, a new set of RFCs obsoleted the documents listed above:

  • RFC 9110: HTTP Semantics
  • RFC 9111: HTTP Caching
  • RFC 9112: HTTP/1.1

So I aim to provide an answer based in the RFC 9110, which is the current reference for the HTTP semantics.

The 302 status code

A response with 302 is a common way of performing URL redirection. Along with the 302 status code, the response should include a Location header with a different URI. Such header will be parsed by the user agent and then perform the redirection:

Redirection example

Web browsers may change from POST to GET in the subsequent request. If this behavior is undesired, the 307 (Temporary Redirect) status code can be used instead.

This is how the 302 status code is defined in the RFC 9110:

6.4.3. 302 Found

The 302 (Found) status code indicates that the target resource
resides temporarily under a different URI. Since the redirection
might be altered on occasion, the client ought to continue to use the
target URI for future requests.

The server SHOULD generate a Location header field in the response
containing a URI reference for the different URI. The user agent MAY
use the Location field value for automatic redirection. The server’s
response content usually contains a short hypertext note with a
hyperlink to the different URI(s).

Note: For historical reasons, a user agent MAY change the
request method from POST to GET for the subsequent request. If
this behavior is undesired, the 307 (Temporary Redirect) status
code can be used instead.

According to MDN web docs from Mozilla, a typical use case for [302]302] is:

The Web page is temporarily not available for reasons that have not been unforeseen. That way, search engines don’t update their links.

Other status codes for redirection

The RFC 9110 defines the following status codes for redirection (some of these status codes were originally defined in other RFCs, but have all been consolidated in the RFC 9110):

  • 301: Moved Permanently
  • 302: Found
  • 307: Temporary Redirect
  • 308: Permanent Redirect

Refer to this answer for further details.

Понравилась статья? Поделить с друзьями:
  • Getlasterror delphi коды ошибок
  • Genshin impact ошибка при запуске приложения 0xc0000142
  • Getelementbyid javascript ошибка
  • Gepard 23 mtv ошибка f75
  • Getcontext 2d ошибка