HTTP 302

From Seobility Wiki
Jump to: navigation, search

What is the HTTP status code 302?

The HTTP status code 302 is an HTTP response code that indicates a resource has been temporarily moved to a different location than the one being accessed. The HTTP status code 302 is a useful way to redirect users from old URLs to new ones, which also works well with search engines. The 302 response code preserves the original URL, with the intention of restoring it at some point in the future.

What are 302 redirects used for?

302 responses are used to redirect an access request from one URL to another. They are most commonly used when web addresses or resource storage locations change. It is important to note that 302 is specifically for temporary redirections. It is intended to enable page requests to be routed to the correct location, but without affecting the URL search engines use when indexing the page.

Examples for 302 redirect implementations

HTTP status codes may be implemented in a number of ways. One of the most common ways to implement them is through the .htaccess file. This is applicable to those running Apache servers, though other server software will typically have a similar feature. An example of a .htaccess 302 redirect is as follows:

<IfModule mod_rewrite.c>
RewriteEngine on
RedirectMatch 302 ^/originalpage/?$ http://website.com/newpage/ 
</IfModule>

You can also use PHP to implement a 302 redirect:

<?php 
header("Location: http://www.new_domain.com");

<?php
header("Location: http://www.domain.com/new_page.php");

A limitation of this implementation is that it can only be used with pages containing HTML. This means that it cannot be used with images or other multimedia file requests.

Content Management Systems may offer plugins or native features that help implement redirects. For example, WordPress supports a wp_redirect() function. This allows programmers to implement a 302 redirect within the code of a website. For those without access to the underlying code, there are also plugins that can be used to implement 302 redirects. An example of this is the Quick Page/Post Redirect Plugin.

Redirects may be chained, though performance can degrade with each subsequent redirect, so they should be limited to as few as possible. You should avoid redirect loops, which can result in pages becoming inaccessible to search engines and visitors.

301 redirect vs 302

HTTP 302
Figure: HTTP 302 - Author: Seobility - License: CC BY-SA 4.0

The difference between using a 301 or 302 response is whether or not the page being requested has moved permanently or temporarily. The HTTP 302 response is intended for temporary redirections. If content is moved permanently, a 301 response should be used instead.

When to use 301 redirects

HTTP 301 redirects are intended to be used when a page or resource has been moved permanently. Using a 301 status code enables search engine crawlers and client browser caches to update indexed URLs. Once a 301 redirect has been accessed, the URL of the original request will be replaced with the redirected URL. This enables sites to preserve search result rankings for the same page when it is moved to a different location.

When to use 302 redirects

Since HTTP 302 redirects are intended to be used for temporary redirects, possible applications include promotional sales pages or A/B tests. Another example would be technical errors or site maintenance.

In these cases, a temporary redirect could be put in place to graciously handle access requests while preventing users from accessing the page. Search engines and browser caches will not forget the original URL and will attempt to access it again on subsequent visits.

Importance of HTTP 302 status codes for SEO

Using HTTP 302 status codes is highly recommended from an SEO perspective. If the location of a resource has changed and no redirect status codes are issued, they will instead return another status code, typically 404. This is the 'page not found' status code, and it indicates a resource was not found at the provided URL.

Search engines such as Google continually recrawl and re-index websites. How often any particular site is re-indexed will depend on many factors, but pages and locations that return 404 status codes will be removed from search results. This means that pages that appear high in search results risk being removed, potentially resulting in major traffic losses.

The key difference between using a 301 or 302 redirect is how search engines and browsers deal with the original URL. When a 301 permanent redirect is used, browser caches and search engine crawl bots update the URL of the resource and do not attempt to access the original URL again. When a 302 temporary redirect is used, browser caches and search engine crawl bots will continue to try to access the original URL in subsequent visits.

In summary: HTTP 302 FAQs

What does the HTTP 302 status code mean?

The HTTP 302 status stands for “Found” and means that a resource has been temporarily relocated to another URL.

How do you implement 302 redirects?

You can implement 302 redirects using the .htaccess file, PHP, or your content management system.

What is the difference between 301 and 302 redirects?

301 redirects mean that a file has been moved permanently, while 302 redirects are used for temporary redirects.

Why is the 302 status code important for SEO?

The 302 status code is relevant for SEO because if you change a file’s location without a redirect, your page might show a 404 error. Resources that return that kind of error will be removed from search results.

Related links

Similar articles

About the author
Seobility S
The Seobility Wiki team consists of seasoned SEOs, digital marketing professionals, and business experts with combined hands-on experience in SEO, online marketing and web development. All our articles went through a multi-level editorial process to provide you with the best possible quality and truly helpful information. Learn more about the people behind the Seobility Wiki.