A couple of weeks ago we received a following question from our reader:
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.
Let’s hear what they suggest for dealing with Magento 302 redirect problem.
Kristina, Marketing Specialist:
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.
Solution for 302 redirects in compare, wishlist, and geolocation/currency switch links in Magento
- 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.