302 redirects in Magento, trying to fix
-
Hi all, I'm assigned a site in Magento. After the first craw, we found almost 15k 302 redirects.
A sample URL ends with this /stores/store/switch/?SID=qdq9mf1u6afgodo1vtvk0ucdpb&___from_store=default&___store=german&uenc=aHR0cHM6Ly9qdWljeWZsdXRlcy5jb20vP19fX3N0b3JlPWdlcm1hbg%2C%2C
And they are currently 302 redirecting to the homepage as well as other main pages and also product pages it seems.
Some of these point to account pages where customers log in. Probably best for me to de-index those so no issues there.
But I'm worried about the 302 redirects to public pages.
The extension we have installed is SEO Suite Ultimate by MageWorx.
Does anyone here have experience here specifically and how did you fix it?
Thanks,
JC
-
It turned out to be a language extension. We took it out and fixed everything except for a couple of links. I'm opening a new question for those. Thanks for all your help!
-
Look at the template, as this is the likely culprit making links to these 302 redirects. If they are not required, simply remove any references to the link on your template?
If they are necessary links as you say, customer login etc - add a nofollow tag and de-index the page.
Ensure you have self-referencing canonical tags on the pages with lots of parameters.
You could also remove the a tag to something less SEO friendly to reduce your potential crawl budget ensuring that your non-vital (product/category) pages exhume more importance.
If you have so many links/pages, they will get lost within all the nonsense.
-
@lasclients Hello, you should debug the redirections in this case. Here's what you can do in Magento 2:
If you face an unexpected 301 or 302 redirect in Magento 2 and you don't know why it happens or what code causes it, you can easily find this out by temporarily editing the following files:
/vendor/magento/framework/HTTP/PhpEnvironment/Response.php /var/www/html/m2_35ee/vendor/magento/framework/Controller/Result/Redirect.php
Open Response.php and add the following line to the beginning of the setRedirect function:
var_dump($url); \Magento\Framework\Debug::backtrace(false, true, false); exit();
Example:
public function setRedirect($url, $code = 302) { var_dump($url); \Magento\Framework\Debug::backtrace(false, true, false); exit(); $this->setHeader('Location', $url, true) ->setHttpResponseCode($code); return $this; }
Now you open the second Redirect.php file and add this:
var_dump($this->url); \Magento\Framework\Debug::backtrace(false, true, false); exit();
After each line containing:
$this->url =
Example:
public function setRefererUrl() { $this->url = $this->redirect->getRefererUrl(); var_dump($this->url); \Magento\Framework\Debug::backtrace(false, true, false); exit(); return $this; } public function setRefererOrBaseUrl() { $this->url = $this->redirect->getRedirectUrl(); var_dump($this->url); \Magento\Framework\Debug::backtrace(false, true, false); exit(); return $this; } public function setUrl($url) { $this->url = $url; var_dump($this->url); \Magento\Framework\Debug::backtrace(false, true, false); exit(); return $this; } public function setPath($path, array $params = []) { $this->url = $this->urlBuilder->getUrl($path, $this->redirect->updatePathParams($params)); var_dump($this->url); \Magento\Framework\Debug::backtrace(false, true, false); exit(); return $this; }
Save the corresponding changes and open a page that causes an unexpected redirect. You should see a debug backtrace with the information about the code line causing the redirect.
If you don't see it, it means that the redirect is not caused by Magento code, but the webserver settings, or the third-party module code that uses not-recommended Magento programming practices.
Hope this helps!
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Over Optimised Magento Pages
We are working on a clients Magento site and we've added new copy which has a decent keyword density which is in line with best practice. When we run it through Moz we are getting a Key Word Stuffing alert saying the page has 27 keywords, where we can only see about 11. This is the page https://www.greatbeanbags.com/bean-bag-cushions The client is pushing back saying the page must have already been optimised before as our new copy has triggered the stuffing alert. But my guess is the page was already stuffed but buy some Magento code we can't see. Any ideas? #magento #Keyworddensity
Content Development | | Marketing_Optimist0 -
Our clients Magento 2 site has lots of obsolete categories. Advice on SEO best practice for setting server level redirects so I can delete them?
Our client's Magento website has been running for at least a decade, so has a lot of old legacy categories for Brands they no longer carry. We're looking to trim down the amount of unnecessary URL Redirects in Magento, so my question is: Is there a way that is SEO efficient to setup permanent redirects at a server level (nginx) that Google will crawl to allow us at some point to delete the categories and Magento URL Redirects? If this is a good practice can you at some point then delete the server redirects as google has marked them as permanent?
Technical SEO | | WillyGx0 -
Our clients Magento 2 site has lots of obsolete categories. Advice on SEO best practice for setting server level redirects so I can delete them?
Our client's Magento website has been running for at least a decade, so has a lot of old legacy categories for Brands they no longer carry. We're looking to trim down the amount of unnecessary URL Redirects in Magento, so my question is: Is there a way that is SEO efficient to setup permanent redirects at a server level (nginx) that Google will crawl to allow us at some point to delete the categories and Magento URL Redirects? If this is a good practice can you at some point then delete the server redirects as google has marked them as permanent?
Technical SEO | | Breemcc0 -
Rel=canonical and redirect on same page
Hi Guys, Am I going slightly mad but why would you want to have a redirect and a canonical redirecting back to the same page. For Instance https://handletrade.co.uk/pull-handles/pull-handles-zcs-range/d'-pull-handle-19mm-dia.-19-x-150mm-ss/?tag=Dia.&page=2 and in the source code:- <link href="<a class="attribute-value">https://handletrade.co.uk/d'-pull-handle-19mm-dia.-19-x-150mm-ss/</a>" rel="<a class="attribute-value">canonical</a>" /> Perfect! exactly what it is intended to do. But then this page is 301 redirected tohttps://handletrade.co.uk/pull-handles/pull-handles-zcs-range/d'-pull-handle-19mm-dia.-19-x-150mm-ss/ The site is built in open cart and I think it's the SEO plugin that needs tweaking. Could this cause poor SERP visibility? This is happening across the whole site. Surely the canonical should just point to the proper page and then there is no need for an additional bounce.
Technical SEO | | nezona1 -
What's with the redirects?
Hi there,
Technical SEO | | HeadStud
I have a strange issue where pages are redirecting to the homepage.Let me explain - my website is http://thedj.com.au Now when I type in www.thedj.com.au/payments it redirects to https://thedj.com.au (even though it should be going to the page https://thedj.com.au/payments). Any idea why this is and how to fix? My htaccess file is below: BEGIN HTTPS Redirection Plugin <ifmodule mod_rewrite.c="">RewriteEngine On
RewriteRule ^home.htm$ https://thedj.com.au/ [R=301,L]
RewriteRule ^photos.htm$ http://photos.thedj.com.au/ [R=301,L]
RewriteRule ^contacts.htm$ https://thedj.com.au/contact-us/ [R=301,L]
RewriteRule ^booking.htm$ https://thedj.com.au/book-dj/ [R=301,L]
RewriteRule ^downloads.htm$ https://thedj.com.au/downloads/ [R=301,L]
RewriteRule ^payonline.htm$ https://thedj.com.au/payments/ [R=301,L]
RewriteRule ^price.htm$ https://thedj.com.au/pricing/ [R=301,L]
RewriteRule ^questions.htm$ https://thedj.com.au/faq/ [R=301,L]
RewriteRule ^links.htm$ https://thedj.com.au/links/ [R=301,L]
RewriteRule ^thankyous/index.htm$ https://thedj.com.au/testimonials/ [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://thedj.com.au/ [L,R=301]</ifmodule> END HTTPS Redirection Plugin BEGIN WordPress <ifmodule mod_rewrite.c="">RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]</ifmodule> END WordPress RewriteCond %{HTTP_HOST} ^mrdj.net.au$ [OR]
RewriteCond %{HTTP_HOST} ^www.mrdj.net.au$
RewriteRule ^/?$ "https://thedj.com.au/" [R=301,L] RewriteCond %{HTTP_HOST} ^mrdj.com.au$ [OR]
RewriteCond %{HTTP_HOST} ^www.mrdj.com.au$
RewriteRule ^/?$ "https://thedj.com.au/" [R=301,L] RewriteCond %{HTTP_HOST} ^thedjs.com.au$ [OR]
RewriteCond %{HTTP_HOST} ^www.thedjs.com.au$
RewriteRule ^/?$ "https://thedj.com.au/" [R=301,L] RewriteCond %{HTTP_HOST} ^theperthweddingdjs.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.theperthweddingdjs.com$
RewriteRule ^/?$ "https://thedj.com.au/" [R=301,L] RewriteCond %{HTTP_HOST} ^thedjs.net.au$ [OR]
RewriteCond %{HTTP_HOST} ^www.thedjs.net.au$
RewriteRule ^/?$ "https://thedj.com.au" [R=301,L]0 -
301 redirect Question
Hi all, I have a client who has a domain lets say www.xyz.de which is redirected 301 to www.zyx.de. Now they're working on a relaunch and they want to use the www.xyz.de as their origibnal doman after that. So, at the end the www.zyx.de - which is indexed by Google - should be redirected to www.xyz.de. It vice versa. So the redirect becomes the original and the original becomes the redirect 😕 Is there anything we have to care off? Or will that run into the hell? Thanx. Seb.
Technical SEO | | TheHecksler0 -
Redirect Error
Hello, I was sent a report from a colleague containing redirect errors: The link to "http://www.xxxx.com/old-page/" has resulted in HTTP redirection to "http://www.xxxx.com/new-page".Search engines can only pass page rankings and other relevant data through a single redirection hop. Using unnecessary redirects can have a negative impact on page ranking. Our site is host on Microsoft Servers (IIS). I'm not sure what is causing these errors. Would it be the way the redirect was implemented.
Technical SEO | | 3mobileIreland0 -
Redirect blogspot blog ?
Hi We have an ecom site selling childrens clothing. We startet up with a blogspot blog due to the lack of that option from our provider. I have a few links in to the blogspot blog and realized today that the PA is 39 - the PA of homepage of ecom site is 40. Ive lately been using the ..../blog on my ecom site. The functionality so far of it is so bad that i am considering using the blogspot blog again. How can i best utilize the strength of our blog at blogspot. Just keep posting w anchor text to relevant pages our main site? Is redirecting a possibility at all ? Dan Lærum
Technical SEO | | danlae0