What a 301 Redirect Looks Like
- Location: https://www.example.com/alternative-page
What is a 302 Redirect?
A 302 redirect communicates to browsers and search engines that a page has moved temporarily. An example of this is when a product page is unavailable and you do not want users to see an error page.
A 302 redirect is used to let search engines know that the previously existing page is unavailable temporarily.
A 302 redirect is also known as a ‘soft’ redirect. The server responds to the request with:
- HTTP/1.1 302 Found Location: https://example.com/alternative-product
The Location header tells the browser the location of a resource. How Does a 302 Redirect Work? There are 5 steps.
- A user visits a URL.
- The browser sends a request to the server for that URL.
- The server retrieves and processes the rule for the temporary redirect.
- The server generates a 302 response and returns it to the browser.
- The browser then loads the resource at the temporary location. The original URL is still the main location and can be active again in the future. Temporary redirect example ORIGINAL URL: example.com/product
302 TEMPORARY DESTINATION: example.com/alternative-product When should you use a 302 redirect? Use a 302 redirect if you plan on bringing the original page back. Examples include:
- Having a store wide sale
- Doing maintenance on your site
- Testing different versions of a landing page
- Temporarily redirecting to a page with a special offer.
- Temporarily removing a product page
- Testing a new layout for your site. A 302 redirect should be used if the page being redirected is only temporarily unavailable.
What is the difference between a 301 and 302 redirect? The main difference is the permanence of the move. A 301 redirect indicates to search engines that the page has moved permanently, while a 302 indicates that the page has moved temporarily. Learn about other differences between 301 and 302 redirects here.
As an example, both redirects can forward users to a different URL. However, they can vary in regards to SEO and caching. The table below lists a comparison of the two types of redirects.
Comparing 301 and 302 Redirects
To further understand these redirects, see the table below.
Feature 301 Redirect 302 Redirect
Purpose To permanently change the location of a resource
To temporarily change the location of a resource
Google may update their index to reflect the new resource location. The original resource location may still be indexed. Caching New resource location may be cached for a long time. Usage Short-term campaigns and tests
Permanent change. Temporary change.
301 redirect Permanently changes the location of a URL. When a URL is permanently changed, signal or resources associated with the old URL should be redirected to the new URL. Example of when to use a 301 redirect: You have a blog post that is located at: https://example.com/blog/seo-tips and you want to change it to: https://example.com/seo-tips Because you will never use the old URL again, a 301 redirect should be used to permanently change the location of the old URL. A 302 redirect temporarily changes the location of a URL. Use a 302 redirect for example if you want to test out a new URL to see how it affects your site and then revert back to the old URL.
A 301 redirect is used for a permanent change in location. Example: If you have a blog post at the following URL: https://example.com/blog/seo-tips and you want to change it to: https://example.com/seo-tips and you will never use the old URL again, then a 301 redirect should be used.
A 302 redirect is used for a temporary change.
For example, you send visitors to a holiday promotion page for two weeks. Once the promotion ends, you want visitors to see the original page again. In this situation you would want to use a 302 redirect.
302 redirects tells visitors and search engines that the page has been temporarily moved.
- SEO Link Equity
Links can also transfer value to other pages. In this case, value is known as link equity.
If an important website links to your blog post, that value can impact your blog post’s visibility on a search engine. What happens to that value though if you delete or move the blog post?
A 301 redirect tells search engines that the new page has taken the place of the old page and thus value should also be transferred to the new page.
A 302 redirect tells search engines that a page has only been moved temporarily. Therefore, the old page is still the preferred page.
In some situations, Google may also treat a 302 redirect as if it were a 301 redirect, especially if there is clear evidence to support the move was permanent. Therefore, always use the redirect type that most accurately represents the situation.
- Caching Differences
Finally, 301 redirects and 302 redirects also differ in caching.
For a 301 redirect, the destination page may be cached in the browser, making subsequent visits faster, but also making it harder to edit the page.
For example, say you accidentally create a 301 redirect on your server. Later, you remove the redirect rule. Although the rule no longer exists on the server, your browser may still be using the old 301 redirect rule to load the page.
A 302 redirect is often considered temporary, but if a page is cached and includes the correct headers, it can be cached.
So, don’t assume every 302 redirect is temporary.
- When to Use Each Redirect
Use a 301 redirect when you want to permanently move a page to a new location.
Use a 302 redirect when you want to temporarily move a page to a new location.
For example, if you change your domain name, use a 301 redirect.
However, if you have a holiday offer on your site and want to temporarily redirect users to that page, use a 302 redirect.
Basically, you should use a 301 redirect if you don’t expect the original page to be accessible in the future.
- 301 vs 302 Redirect: Which is Better for SEO?
Website owners are frequently interested in which of the two redirect types is better for SEO.
Neither is better for SEO.
A 301 redirect should be used for permanent change of a URL.
Search engines then understand to remove the old page and replace it with the new one.
For instance, if an old page on your site with a 301 redirect to a new page has 5000 monthly visitors, and you want to change the URL of that page, using a 301 redirect allows search engines to transfer their ranking signals to the new page and helps minimize loss of SEO value.
If you used a 302 redirect for this change, search engines may assume that the old page is temporarily unavailable and may not transfer ranking signals to the new page.
Search engines can also follow the 301 redirect to the new page and consolidate ranking signals to that page.
Search engines may not immediately update their results to reflect the new page. For example, if the page has been moved permanently to a new location using a 301 redirect, search engines may still consider the old location as the canonical version of the page.
Yes, a 301 redirect will pass and consolidate the link equity to the new page. Google has stated that a permanent redirect will not lose page rank.
Although Google has said that page rank is not lost with a permanent redirect, this does not mean that the new page will gain the same rankings as the old page.
There are other factors that affect rankings such as: the quality of the content, search intent, internal and external links, relevance to the query, website and page structure, and page experience.
Therefore, a 301 redirect will transfer some of the rankings signals to the new page, but it may not achieve the same rankings. Using a 302 redirect will not negatively impact your SEO. In some cases it may even be helpful. For instance, if you want to direct users to a page that is only relevant and useful for a limited time, a 302 redirect may be a good option. In this case, a 302 redirect tells search engines that the original page will be back and the current page is only temporary. There are many situations where a 302 redirect may be appropriate, but using it for a permanent redirect is incorrect and may cause problems.
301 and 302 redirect examples
Here are some examples to help you determine when to use each type of redirect.
- Example 1: Changing a Blog URL
You have an old blog post with a URL of:
- https://example.com/2024/seo-guide
You want to change the URL to:
- https://example.com/seo-guide
You want to use this new URL to permanently redirect to the post.
To do this, you need to create a 301 redirect.
Example: 301 for a Changed Blog URL
- Location: https://example.com/seo-guide
This lets the search engine know the location of the post.
- Example 2: Temporary Replacement of a Product
Suppose you have a product on your site with the following URL:
- https://example.com/red-shoes
You are temporarily out of this product.
You want visitors to be taken to this temporary product page:
- https://example.com/similar-shoes
A 302 redirect should be created with the following code. The redirect can be removed when the product becomes available again.
Example: 302 for a Missing Product
- Location: https://example.com/similar-shoes
- Example 3: Change of Domain Name
Initially your website was on the domain:
- http://oldwebsite.com
Now it is on:
- https://newwebsite.com
To permanently redirect visitors to the new domain, a 301 redirect should be created with the following code:
Example: 301 for a New Domain
- Location: https://newwebsite.com/
Along with a 301 redirect for the domain, individual page redirects should also be created to allow visitors to reach specific content instead of always redirecting to the home page.
- Example 4: Temporary Website Work
You want to block your site from visitors for a few hours while you do some maintenance.
You create a page for visitors to see while you do the work.
- https://example.com/maintenance
Your normal home page is:
- https://example.com/
Use a 302 redirect to temporarily redirect visitors to the maintenance page.
After the maintenance work is complete, remove the redirect to restore the home page to the normal site.
How to Create a 301 Redirect
There are several ways to create a 301 redirect.
The most effective method depends upon your website platform and your server. Listed below are three methods.
- Creating a 301 Redirect with .htaccess
This method is effective for websites using the Apache web server.
The .htaccess file lets you configure various settings, including redirects.
Log in to your website’s hosting control panel and open the File Manager.
Open the public website folder, which is commonly named public_html.
Locate the .htaccess file. Before modifying the file, create a copy of it to keep as a backup.
Edit the file and add the following code:
- Redirect 301 /old-page https://example.com/new-page
In the example above, all visitors to the old page at the example.com domain would be redirected to the new page at that domain. To redirect visitors to a new page on a different domain, you would use the following code.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^oldwebsite.com$ [NC]
RewriteRule ^(.*) https://newwebsite.com/$1 [R=301,L] The first line turns on URL rewriting. The second line checks to see if the request is being made to the old domain. The final line changes the request domain to the new domain and creates a permanent 301 redirect.
Make sure your new domain and SSL are fully functional before testing the redirect. It is also good practice to avoid creating multiple, redundant redirects.
- Creating a 301 Redirect with Nginx
If your web server uses Nginx, the configuration format will be different.
Open the configuration file for your Nginx server. The location of this file varies based on your hosting configuration.
Locate the server block for your website.
Add the following code to the server block: location = /old-page { return 301 https://example.com/new-page; }
Add this rule:
location = /old-page {
- return 301 https://example.com/new-page;
}
This rule will redirect users visiting the old page to the new page.
To fully redirect the domain name use this code instead:
server {
listen 80;
server_name oldwebsite.com www.oldwebsite.com;
- return 301 https://newwebsite.com$request_uri;
}
This code will fully redirect a domain name with all the requested URLs to the new domain name and corresponding URLs.
For example:
- Requested URL http://oldwebsite.com/about
will be fully redirected to
- https://newwebsite.com/about
Test the configuration of your Nginx server using the following command:
sudo nginx -t
If there are no syntax errors, you can reload Nginx to apply the changes:
sudo systemctl reload nginx
You may need administrative privileges to do the changes above. 3. Set Up a 301 Redirect in WordPress
Most users can create redirects in WordPress without the need to edit the server configuration files.
As an example, the Redirection plugin can also be used for the same purpose.
To create a redirect using this plugin:
- Log into your WordPress website.
- Select Plugins from the dashboard.
- Select Add New.
- Search for and select the Redirection plugin.
- Click Install.
- Click Activate.
- From the sidebar, select Tools and then Redirection.
- Enter the old URL.
- Enter the new URL.
- Click Add Redirect.
Use the following to create a redirect in the plugin:
- Source URL: /old-page
- Target URL: https://example.com/new-page
Check the type of redirect used and edit it to be a 301 permanent redirect if necessary, prior to saving.
How to Set Up a 302 Redirect
The process to set up a 302 redirect is quite similar to the process to set up a 301 redirect. The main difference is the status code.
Use 302 instead of 301.
Now, let’s look at each of these in more detail.
- Using .htaccess to Set Up a 302 Redirect
First, open the .htaccess file located in the public folder of your website. Next, add the following code to the file: Redirect 302 /temporary-page https://example.com/special-offer This code tells visitors’ browsers to go to the special offer page from the temporary page.
You should remove this rule once your special offer is no longer valid.
- Using Nginx to Set Up a 302 Redirect
First, locate the correct server block in your Nginx configuration file. Next, add the following code to the block: location = /temporary-page { return 302 https://example.com/special-offer; } Lastly, test your configuration file by using the command ‘sudo nginx -t’. If the configuration is successful, use the command ‘sudo systemctl reload nginx’ to update Nginx. As with the .htaccess method, remove this rule once your special offer ends.
- Setting up a 302 Redirect in WordPress
You can also use the Redirection plugin to set up a 302 redirect in WordPress. From your WordPress dashboard, go to Tools > Redirection. Enter /temporary-page in the Source URL box and enter https://example.com/special-offer in the Target URL box. Select 302 Found from the drop down menu. Once you’ve entered the information, click Add Redirect. Remove the redirect once your special offer is no longer available.
Testing a Redirect is Easy
It’s always a good idea to test your redirects after you’ve set them up. Testing your redirects ensures that the server is returning the proper status code. There are several easy methods to test your redirects.
- Method 1: Test Using Your Browser
Test 1: Go to Google Chrome, and enter the URL you want to test. Right click on the page and select “Inspect.” Select the “Network” tab and refresh the page. Look for the first entry and note the status code. It should be either a 301 or 302. Testing redirects using your browser can give you preliminary results but for more in depth information, an online redirect checker can be of greater assistance.
- Test 2: Online Redirect Checker
One online tool you can use is httpstatus.io. Enter the URL you wish to test and run the check. You will get the following information: The status code of the redirect, the location of the redirect to, and a description of the redirect chain. If there are multiple redirects leading to the final location, you will see that as well.
- Method 3: Using the Command Line
You can also use the command line to check redirects. Using the cURL command, you can check the redirect status of any URL like this: curl -I https://example.com/old-page cURL will show all status codes of the redirect chain. For a more detailed description of the headers of each redirect in the chain, use the command curl -IL https://example.com/old-page. cURL is a good option for both website owners and developers.
Typical Blunders Made When Using Redirects
Creating redirects is relatively simple. But configuring them correctly can be tricky, and can impact your SEO negatively.
Here are some common mistakes.
- Using a 302 for a Permanent Redirect
Using a 302 when you should be using a 301 is probably the most common error made when implementing redirects.
Let’s say you move a blog post to a new location.
If you configure a 302 redirect to the new location, the search engine will not recognize the new location of the blog post and will continue to direct users to the old location.
A 301 redirect should be implemented to signal to search engines that the old location of the blog post should no longer be used.
- Using a 301 for a Temporary Redirect
Using a 301 tells search engines that the old location should never be used again to locate the page.
If you only want the page to be unavailable for a short period of time, a 302 redirect should be used.
- Redirect Chains
If a single URL is redirected to a second URL which then redirects to a third URL, this is known as a redirect chain.
E.g.
A single URL redirects to B which then redirects to C.
Redirect chains add unnecessary steps to the process and can be difficult to manage. To eliminate this, the first URL should be redirected directly to the last URL in the chain.
- Redirect Loops
This occurs when two or more URLs redirect to each other creating an infinite loop.
E.g. A redirects to B, and B redirects to A.
This will result in an error message being displayed to the user.
Always test your redirect rules before implementing them.
- Redirecting All Old Pages to the Home Page
Let’s say you delete 20 blog posts. Rather than redirecting each old URL to the appropriate new page, you redirect all of them to the home page. This creates a poor user experience, and may negatively affect your search engine results. Instead, redirect each old URL to the new, relevant page if one exists. If there is no new relevant page, return a proper 404 or 410 response.
- Neglecting Internal Links
After you implement a redirect to point visitors to a new page, your site may still contain links to the old page. So for example, if your menu is still linked to the old page, then a user would still experience an unnecessary delay in loading the new page. Redirects can also be avoided by removing old links and replacing them with the new ones.
- Neglecting Your Sitemap
After moving a page to a new URL, be sure to also update your XML sitemap to reflect the new URL. This ensures the search engine crawlers also update their pages to reflect the change.
- Neglecting HTTPS
Lastly, if you move your site to HTTPS, all your redirects should also be changed to HTTPS. So for example, ‘http://www.example.com/page’ should now redirect to ‘https://www.example.com/page’. In addition, you should also update all internal links to use HTTPS. Best Practices for 301 and 302 Redirects
Good management of your redirects is critical to the health of your website. Here are some basics to implement.
- Use a 301 status code for a permanent move, or 302 for a temporary move.
- Direct visitors to the most relevant page.
- Minimize the use of redirects.
Edit for 301 and 302 Redirect Strategy.
- Check for Redirect Loops: Make sure users can’t be redirected to a previous step in the process.
- Adjust internal links: Edit your links to go to the right page.
- Update your Sitemap: with correct URLs.
- Test all your redirects: to make sure they work and go to the right place.
- Maintain some Old URLs: Don’t remove redirects unless necessary.
- Use HTTPS: Have your website host use secure URLs.
- Monitor the Search Console: for indexing issues.
- Save Old and New URLs: for future reference.
- Remove temporary redirects: Permanent redirect should be put in place when the temporary one is taken down. This includes restoring the page that was replaced with the temporary redirect.
Also, review your redirects after major website changes.
This helps identify issues users may have when visiting your site.
301 vs 302 Redirects
Now that you know how both redirects work, let’s look at how to implement them to your site. The question you should ask yourself is, “will the original URL be returned in the future?” If the answer is no, use a 301 redirect. If the answer is yes, use a 302 redirect.
Some examples are as follows.
You Situation Recommended Redirect
You have permanently changed a blog URL 301
You have moved to a new domain 301
You have switched from HTTP to HTTPS 301
You have merged two articles 301
You are temporarily redirecting a product page 302
You are running a short promotion 302
You are doing temporary maintenance 302
You are temporarily using a new landing page 302
You have permanently replaced an old page with a new one 301
You have temporarily changed the destination of a page 302
In any case, you always want to choose a redirect that best reflects the purpose of the website move, rather than choosing one simply based on how it may impact your SEO.
Common Questions About 301 and 302 Redirect
Here are 18 common questions about 301 and 302 redirects.
- What is the difference between a 301 and 302 redirect?
A 301 redirect is used to indicate that a page has been permanently moved. A 302 is used to indicate a page has been temporarily moved.
- Which redirect is better to use for SEO?
In general, use a 301 redirect for change of URLs.
- Does a 301 pass link equity?
Yes.
- Does a 302 pass link equity?
Yes.
- Can a 302 hurt my site's SEO?
No, as long as it is used for a temporary change. Problems occur when a 302 is used to represent a permanent URL change.
- What about a 301 redirect when changing domains?
You should always use a 301 redirect when moving your site to a new domain.
- Can I change a 302 redirect to a 301 redirect?
Yes, this change can be made on your server or via your WordPress plugin.
- Can I change a 301 redirect to a 302 redirect?
Yes, although some browsers may have cached the old 301 redirect and will still attempt to reach the old URL. In this case you would need to clear your browser's cache and test the new redirect.
- Does Google follow 302 redirects?
Yes, Google will follow 302 redirects.
- How long should I keep a 301 redirect?
Keep the 301 redirect in place for as long as possible.
- How long should I use a 302 redirect?
Keep the 302 redirect in place for as long as the change is necessary.
- Should I use a 302 redirect for a website redesign?
Yes, if the change is temporary and the original URL will be reinstated. Use 301 redirects for permanent changes.
- Do 301 redirects impact site speed?
A single 301 redirect likely will not impact site speed.
- Is it possible to use a 301 redirect to redirect several URLs?
Yes.
- What is HTTP 301 Moved Permanently?
When a resource is permanently moved to a new location, this status code is used to inform both browsers and search engines.
- What is HTTP 302 Found?
If a resource is temporarily available at a different location, this status code is used to communicate this to browsers and search engines.
- Can I generate 301 and 302 redirects in WordPress?
Yes. You can do this in WordPress using redirect plugins, for example Redirection, without the need to modify your server configuration files.
- How can I test my redirect?
You can use the Chrome Developer Tools or an online tool to check the destination and the status code using cURL.
Final Thoughts
Learning the difference between 301 and 302 redirects is important for effectively utilizing redirects on your website.
Both of these types of redirects permanently or temporarily move website visitors to a new location.
Use a 301 redirect when the content at the requested URL has permanently moved to a new location.
Use a 302 redirect when the content at the requested URL has moved temporarily to a new location.
In general, a 301 redirect is used to change the permanent location of a web page, and a 302 redirect is used to change the location of a web page on a temporary basis.
It is also important to test your redirects to make sure they are working correctly and to eliminate any redirect chains. You should also fix broken links on your site and update your sitemap.
The most important thing is to use the right type of redirect. Using the correct type of redirect allows visitors to the site to easily locate the content they are looking for and lets search engines figure out the purpose of your site.