#Magento 302 redirect issue: how to handle

Table of Content

#Magento 302 redirect issue: how to handle

A couple of weeks ago we received a following question from our reader:

Сlay "How would I make urls such as WISH LIST, currency switcher and product compare 301 instead of 302? Is there code that I can update? What in Magento source code sets this? Currently with x-number of pages all have compare buttons, currency symbols, etc, I have a ton of 302s that are hurting me."
 

Before answering this question, I investigated what Magento community members are writing about the case and which actions they suggest. In fact, there are lots of questions on this topic, but in most of the cases I didn't see a proper answer. That's why I consulted with my colleagues, Kristina, a marketing specialist with focus on SEO, and Andrew, a skilled system administrator.

Redirect your visitors to a needed page based on their location. Try out our Magento 1 and Magento 2 GeoIP extension.

Let's hear what they suggest for dealing with Magento 302 redirect problem.

Kristina, Marketing Specialist:

Kristina, Amasty Marketing Manager
301 redirect vs 302 redirect

When a customer is redirected from one page to another, he doesn’t care which redirect is used. Search engines are the ones who care about redirect type. They handle 301 and 302 redirects differently: the first one is permanent, and the second is temporary.

A 301 redirect is considered to be a real savior when it comes to SEO. It passes the link juice from one page to another, thus, you don’t lose traffic and rankings. A 302 redirect doesn’t pass any link juice and is considered to be harmful for SEO.

But let’s dig deeper.

Situation 1. You have a page A that is outdated, and you create a page B with relevant information instead. In this case B is an updated version of A and generally substitutes it. This means you should tell Google to serve the page B instead of the page A permanently, i.e. use a 301 redirect.

So here we have: Page A (no longer needed), Page B (currently relevant), the relations between them can be characterized as substitution.

Situation 2. Some pages of your site are visible to signed in users only. If a guest tries to access it, he is redirected to a login page. In this case there is no need to use a 301 HTTP code as there is neither out-of-date nor up-to-date content.

Not all 302 redirects are equally bad

You can see from the above examples that sometimes 302 redirects usage is fully justified, so why do people continue to ask how to replace all the possible 302 redirects with 301 ones?

One reason is that different SEO tools flag 302 as errors. On the one hand, that’s OK as most 302 redirects used on the sites are meant to be 301. But on the other hand, there is a small percentage of those redirects that should be kept 302 and not treated as SEO issues.

The problem is that each tool generalizes redirects usage: a 302 HTTP response is treated as bad, and 301 – as good. But there is no only black and white either in life or in SEO, do you get what I mean?

So what about Magento 302 redirects?

Most widespread examples of mass 302 usage in Magento are:

  • Add to compare links
  • Add to wishlist links
  • Geolocation and currency switch links

Some Magento store owners try to figure out how to replace those 302 redirects with 301 ones. But do they really need to do it?

Remember our Situation 1? Here we had an out-of-date page and an up-to-date page that substitutes the former. Do we have the same pattern with wishlist links, for example? No! We don’t need Google to treat the first page as an updated version of another one.

But what about the link juice? A page gets it provided other sites link to it. I don’t think there are people who specifically copy wishlist (or compare, etc.) URLs and use them to link to the site (anyway, stop, if you do =). So what is the SEO purpose of 301 redirects for such pages? There isn’t one.

  • Keep the 302 redirects
  • Disallow indexing of these URLs in your robots.txt file (e.g. Disallow:/catalog/product_compare/)
  • Relax and think about more serious issues that can be solved
Andrew, System Administrator:

Why you definitely don't want to replace 302 redirects with 301 ones manually

Wrong 301 redirect usage could lead to unwanted consequences. And I’m talking not about SEO and search engines, but about browsers that are used by your Magento store visitors.

Modern browsers cache 301 redirect results and when visiting the initial page for the second time go to the redirected page without actually requesting the initial page from the web server.

Say, you have a /products/my-cool-product.html page, and you changed its URL to /products/My-Cool-Product.html by adding a 301 redirect from /products/my-cool-product.html to /products/My-Cool-Product.html.

After some time you decide to rename the page once again, for example, to /products/Cool-Product.html, using the 301 redirect again, having this algorithm:

/products/my-cool-product.html → 301 → /products/My-Cool-Product.html

/products/My-Cool-Product.html → 301 → /products/Cool-Product.html

If you decide to go back and call the changes off, browsers cache will still store a redirect to the new variant depending on when the users visited the page. To make this finally work, you should manually (through htaccess or URL Redirects) add redirects to the initial page:

/products/Cool-Product.html → 301 → /products/my-cool-product.html

/products/My-Cool-Product.html → 301 → /products/my-cool-product.html

Otherwise, many visitors of /products/my-cool-product.html will appear on /products/My-Cool-Product.html, and without the reverse redirect they’ll see the 404 error page, which may lead to abandoning the store and losing clients.

I’m not even mentioning the fact that changing some default Magento structures without proper understanding of your actions may lead to issues like redirect loops and inoperative links.

Thus, I agree on what Kristina suggests when dealing with 302 redirects in Magento.

We do hope these instructions were helpful for you. If you have any questions left on this topic, welcome to ask in comments.

May 19, 2015
July 21, 2015
April 17, 2015
Comments
visitor
May 28, 2015
What do you think about 302 redirects on search query redirects? Currently when you make a redirect for an often searched term to a specific product page, it is a 302 redirect. How can we make it 301 redirect? Is there a code we need to change? I think it will be very helpful when a search engine has a search page for a search term indexed instead of the actual product page.
Reply
Ksenia Dobreva
June 1, 2015
Hey there, well, if you want, you may change it to 301 here, but we strongly recommend to use some help of a professional developer, as it's easy to screw everything up. But why do you need to do this with site search results? Normally it is advised to hide site search results from indexing, as Google doesn't want them in general: https://www.mattcutts.com/blog/search-results-in-search-results/ And if you de-index them, you don't have to worry about 302 redirects. There are rare cases when we want to get some of the search results indexed, so do you have any special reasons for that? Hope that helps.
gunnar
July 10, 2018
how about a 302 redirect from the http to the https version of a Magento Store? I'd say the https site qualifies as a 'substitute' as per your definition so it should use a 301 redirect here. It seems by default Magento is using 302 redirects for the http ---> https forwarding though. So I'm wondering whether there is a any good reason behind that practice. anyone?
Reply
Leave your comment

Your email address will not be published

This blog was created with Amasty Blog Pro

This blog was created with Amasty Blog Pro

© 2009-2024 Amasty. All Rights Reserved.