undefined
Skip to content
Moz logo Menu open Menu close
  • Products
    • Moz Pro
    • Moz Pro Home
    • Moz Local
    • Moz Local Home
    • STAT
    • Moz API
    • Moz API Home
    • Compare SEO Products
    • Moz Data
  • Free SEO Tools
    • Domain Analysis
    • Keyword Explorer
    • Link Explorer
    • Competitive Research
    • MozBar
    • More Free SEO Tools
  • Learn SEO
    • Beginner's Guide to SEO
    • SEO Learning Center
    • Moz Academy
    • SEO Q&A
    • Webinars, Whitepapers, & Guides
  • Blog
  • Why Moz
    • Agency Solutions
    • Enterprise Solutions
    • Small Business Solutions
    • Case Studies
    • The Moz Story
    • New Releases
  • Log in
  • Log out
  • Products
    • Moz Pro

      Your all-in-one suite of SEO essentials.

    • Moz Local

      Raise your local SEO visibility with complete local SEO management.

    • STAT

      SERP tracking and analytics for enterprise SEO experts.

    • Moz API

      Power your SEO with our index of over 44 trillion links.

    • Compare SEO Products

      See which Moz SEO solution best meets your business needs.

    • Moz Data

      Power your SEO strategy & AI models with custom data solutions.

    NEW Keyword Suggestions by Topic
    Moz Pro

    NEW Keyword Suggestions by Topic

    Learn more
  • Free SEO Tools
    • Domain Analysis

      Get top competitive SEO metrics like DA, top pages and more.

    • Keyword Explorer

      Find traffic-driving keywords with our 1.25 billion+ keyword index.

    • Link Explorer

      Explore over 40 trillion links for powerful backlink data.

    • Competitive Research

      Uncover valuable insights on your organic search competitors.

    • MozBar

      See top SEO metrics for free as you browse the web.

    • More Free SEO Tools

      Explore all the free SEO tools Moz has to offer.

    NEW Keyword Suggestions by Topic
    Moz Pro

    NEW Keyword Suggestions by Topic

    Learn more
  • Learn SEO
    • Beginner's Guide to SEO

      The #1 most popular introduction to SEO, trusted by millions.

    • SEO Learning Center

      Broaden your knowledge with SEO resources for all skill levels.

    • On-Demand Webinars

      Learn modern SEO best practices from industry experts.

    • How-To Guides

      Step-by-step guides to search success from the authority on SEO.

    • Moz Academy

      Upskill and get certified with on-demand courses & certifications.

    • SEO Q&A

      Insights & discussions from an SEO community of 500,000+.

    Unlock flexible pricing & new endpoints
    Moz API

    Unlock flexible pricing & new endpoints

    Find your plan
  • Blog
  • Why Moz
    • Small Business Solutions

      Uncover insights to make smarter marketing decisions in less time.

    • Agency Solutions

      Earn & keep valuable clients with unparalleled data & insights.

    • Enterprise Solutions

      Gain a competitive edge in the ever-changing world of search.

    • The Moz Story

      Moz was the first & remains the most trusted SEO company.

    • Case Studies

      Explore how Moz drives ROI with a proven track record of success.

    • New Releases

      Get the scoop on the latest and greatest from Moz.

    Surface actionable competitive intel
    New Feature

    Surface actionable competitive intel

    Learn More
  • Log in
    • Moz Pro
    • Moz Local
    • Moz Local Dashboard
    • Moz API
    • Moz API Dashboard
    • Moz Academy
  • Avatar
    • Moz Home
    • Notifications
    • Account & Billing
    • Manage Users
    • Community Profile
    • My Q&A
    • My Videos
    • Log Out

The Moz Q&A Forum

  • Forum
  • Questions
  • Users
  • Ask the Community

Welcome to the Q&A Forum

Browse the forum for helpful insights and fresh discussions about all things SEO.

  1. Home
  2. SEO Tactics
  3. Technical SEO
  4. 302 redirects in Magento, trying to fix

Moz Q&A is closed.

After more than 13 years, and tens of thousands of questions, Moz Q&A closed on 12th December 2024. Whilst we’re not completely removing the content - many posts will still be possible to view - we have locked both new posts and new replies. More details here.

302 redirects in Magento, trying to fix

Technical SEO
magento 302
3
4
3.9k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as question
Log in to reply
This topic has been deleted. Only users with question management privileges can see it.
  • LASClients
    LASClients last edited by Sep 10, 2021, 8:28 PM

    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

    tir17 1 Reply Last reply Sep 18, 2021, 5:05 AM Reply Quote 0
    • LASClients
      LASClients last edited by Sep 30, 2021, 11:12 PM

      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!

      1 Reply Last reply Reply Quote 0
      • terryseos
        terryseos last edited by Sep 18, 2021, 8:03 AM

        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.

        1 Reply Last reply Reply Quote 0
        • tir17
          tir17 @LASClients last edited by Sep 18, 2021, 5:05 AM

          @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!

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          1 out of 4
          • First post
            1/4
            Last post

          Got a burning SEO question?

          Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.


          Start my free trial


          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.

          • See all categories

          Related Questions

          • Damian_Ed 0

            Unsolved Temporary redirect from 302 to 301 for PNG File?

            302 temporary riderect 301 http status image issue

            #302HTTP #temporaryredirect
            Hi everyone, Recently I have faced a crawl issue with my media images on website. For example this page url https://intreface.com/wp-content/uploads/2022/12/Horion-screen-side-2.png has 302 HTTP Status and the recommendation is to change it 301. I have read the article on temporary redirections here:
            https://moz.com/learn/seo/redirection?_ga=2.45324708.1293586627.1702571936-916254120.1702571936
            but its not written here how to redirect in my HTML 1 image url not the landing page.
            Screenshot 2023-12-15 at 11.02.40.png
            I have messaged to MOZ Support but they recommended to go for the MOZ Community!
            Screenshot 2023-12-15 at 11.06.02.png Could you assist me wit this issue please? I can reach HTTML of the necessary page and change what I need for permanent redirection but firstly I need to understand how to do that correctly.

            Technical SEO | Jan 23, 2024, 5:26 AM | Damian_Ed 0
            0
          • Breemcc

            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?

            magento nginx

            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 | Sep 23, 2023, 10:06 PM | Breemcc
            0
          • photoseo1

            Redirecting an Entire Website?

            redirecting domain redirect former site

            Is it best to redirect an old website to a new website page by page to like pages or just the entire site all at once to the home page of the new site? I do have about 10 good pages on the site that are worth directing to corresponding pages on the new site. Just trying to figure out what is going to preserve the most link juice. Thanks for the help!

            Technical SEO | Apr 7, 2024, 8:55 AM | photoseo1
            0
          • fJ66doneOIdDpj

            Multilang site: Auto redirect 301 or 302?

            redirect 301 redirect 302 international seo

            We need to establish if 301 or 302 response code is to be used for our auto redirects based on Accept-Language header. https://domain.com
            30x > https://domain.com/en
            30x > https://domain.com/ru
            30x > https://domain.com/de The site architecture is set up with proper inline HREFLANG.
            We have read different opinions about this, Ahrefs says 302 is the correct one:
            https://ahrefs.com/blog/301-vs-302-redirects/
            302 redirect:
            "You want to redirect users to the right version of the site for them (based on location/language)." You could argue that the root redirect is never permanent as it varies based on user language settings (302)
            On the other hand, the lang specific redirects are permanent per language: IF Accept-Language header = en
            https://domain.com > 301 > https://domain.com/en
            IF Accept-Language header = ru
            https://domain.com > 301 > https://domain.com/ru So each of these is 'permanent'. So which is the correct?

            International SEO | Oct 11, 2022, 2:10 AM | fJ66doneOIdDpj
            0
          • tidybooks

            Issues with Magento layered navigation

            Hi, We use Magento v.1.7 for our store. We have recently had an SEO audit and we have uncovered 2 major issues which can be pinpointed to our layered navigation. We use the MANAdev layered navigation module. There are numerous options available to help with SEO. All our filtered urls seem to be fine ie. https://www.tidy-books.co.uk/childrens-bookcases-shelves/colour/natural-finish-with-letters/letters/lowercase have canonical url correctly setup and the meta tags as noindex, follow  but Magento is churning out tons of 404 error pages like this https://www.tidy-books.co.uk/childrens-bookcases-shelves/show/12/l/colour:24-4-9/letters:6-7 which google  is indexing I'm at lost at how to solve this any help would be great. Thank you **This is from our SEO audit report ** The faceted navigation isn’t handled correctly and causes two major issues:● One of the faceted navigation filters causes 404 error. This means that the error isappended each sequence of the navigation options, multiplying the faulty URLs.● The pages created by the faceted nav are all accessible to the search engines. Thismeans that there are hundreds of duplicated category pages created by one of theparameters. The duplication issues can seriously hinder the organic visibility.The amount of 404 errors and the duplicated pages created by faceted navigation makes italmost impossible for a search engine crawler to finish the crawl. This means that the sitemight not be fully indexed and the newly introduced product pages or content won’t bediscovered for a very long time.

            Technical SEO | Sep 22, 2016, 1:03 PM | tidybooks
            0
          • Houdoe

            CNAME vs 301 redirect

            Hi all, Recently I created a website for a new client and my next job is trying to get them higher in Google. I added them in OSE and noticed some strange backlinks. To my surprise the client has about 20 domain names. All automatically poiting to (showing) the same new mainsite now. www.maindomain.nl www.maindomain.be
            www.maindomain.eu
            www.maindomain.com
            www.otherdomain.nl
            www.otherdomain.com
            ... Some of these domains have backlinks too (but not so much). I suggested to 301 redirect them all to the main site. Just to avoid duplicate content. But now the webhoster comes into play: "It's a problem, client has only 1 hosting account, blablabla...". They told me they could CNAME the 20 domains to the main domain. Or A-record them to an IP address. This is too technical stuff for me. So my concrete questions are: Is it smart to do anything at all or am I just harming my client? The main site is ranking pretty well now. And some backlinks are from their copy sites (probably because everywhere the logo links to the full mainsite url). Does the CNAME or A-record solution has the same effect as a 301 redirect, from SEO perspective? Many thanks,
            Hans

            Technical SEO | Aug 19, 2013, 12:24 PM | Houdoe
            0
          • TroyW

            301 Redirect with index.asp

            I am very new to all of this so forgive the newbie questions I will get better.   Ok so after starting a campaign I see that I have many issues including where some pages are being deemed as duplicate content. 1. The report says the http://lucid8.com has duplicate content on 2 other pages 2. When I look at them it shows that http://lucid8.com/index.asp and http://www.lucid8.com are duplicates. 3. Really these are the exactly the same page because the default page that is opened for www.lucid8.com http://www.lucid8.com etc always opens the index.asp page. 4. Now I read that I should do permanent redirects and how to do this via IIS and I tried to do a redirect from index.asp to www.lucid8.com but that does not work because www.lucid8.com is pointing to index.asp and so we end up in a circle. So the question is how do I get rid of these duplicate page references without causing problems. Thanks

            Technical SEO | Apr 25, 2013, 5:49 PM | TroyW
            0
          • Juandbbam

            301 redirect from Blogger

            Hello, I have a client with a Wordpress network of blogs, each blog is owned by a different blogger. Many of them were migrated time ago from Blogger. I have seen that the way used to redirect them is a meta refresh, so no authority is being passed. I cannot find any reliable way of making a 301 from Blogger, There are some plugins, but I'm afraid of using them. Any of you have experience with this situation please? I have even thought about placing a global rel canonical before the meta refresh, but I think that here the problem is the meta refresh itself.... Thank you in advance

            Technical SEO | Jan 16, 2013, 4:33 AM | Juandbbam
            0

          Get started with Moz Pro!

          Unlock the power of advanced SEO tools and data-driven insights.

          Start my free trial
          Products
          • Moz Pro
          • Moz Local
          • Moz API
          • Moz Data
          • STAT
          • Product Updates
          Moz Solutions
          • SMB Solutions
          • Agency Solutions
          • Enterprise Solutions
          Free SEO Tools
          • Domain Authority Checker
          • Link Explorer
          • Keyword Explorer
          • Competitive Research
          • Brand Authority Checker
          • Local Citation Checker
          • MozBar Extension
          • MozCast
          Resources
          • Blog
          • SEO Learning Center
          • Help Hub
          • Beginner's Guide to SEO
          • How-to Guides
          • Moz Academy
          • API Docs
          About Moz
          • About
          • Team
          • Careers
          • Contact
          Why Moz
          • Case Studies
          • Testimonials
          Get Involved
          • Become an Affiliate
          • MozCon
          • Webinars
          • Practical Marketer Series
          • MozPod
          Connect with us

          Contact the Help team

          Join our newsletter
          Moz logo
          © 2021 - 2025 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
          • Accessibility
          • Terms of Use
          • Privacy

          Looks like your connection to Moz was lost, please wait while we try to reconnect.