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
- 
					
					
					
					
 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.phpOpen 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 ToolsChat with the community about the Moz tools. 
- 
		
		SEO TacticsDiscuss the SEO process with fellow marketers 
- 
		
		CommunityDiscuss industry events, jobs, and news! 
- 
		
		Digital MarketingChat about tactics outside of SEO 
- 
		
		Research & TrendsDive into research and trends in the search industry. 
- 
		
		SupportConnect on product support and feature requests. 
Related Questions
- 
		
		
		
		
		
		Unsolved Temporary redirect from 302 to 301 for PNG File?
 #302HTTP #temporaryredirect Technical SEO | | Damian_Ed 0
 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.0
- 
		
		
		
		
		
		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
- 
		
		
		
		
		
		What is the difference between 301 redirects and backlinks?
 i have seen some 301 redirects on my site billsonline, can anyone please explain the difference between backlinks and 301 redirects, i have read some articles where the writer was stating that 301 are not good for website. Technical SEO | | aliho0
- 
		
		
		
		
		
		Why does my Google Web Cache Redirects to My Homepage?
 Why does my Google Webcache appears in a short period of time and then automatically redirects to my homepage? Is there something wrong with my robots.txt? The only files that I have blocked is below: User-agent: * Disallow: /bin/ Disallow: /common/ Disallow: /css/ Disallow: /download/ Disallow: /images/ Disallow: /medias/ Disallow: /ClientInfo.aspx Disallow: /*affiliateId* Disallow: /*referral* Technical SEO | | Francis.Magos0
- 
		
		
		
		
		
		Redirect URLS with 301 twice
 Hello, I had asked my client to ask her web developer to move to a more simplified URL structure. There was a folder called "home" after the root which served no purpose. I asked for the URLs to be redirected using 301 to the new URLs which did not have this structure. However, the web developer didn't agree and decided to just rename the "home" folder "p". I don't know why he did this. We argued the case and he then created the URL structure we wanted. Initially he had 301 redirected the old URLS (the one with "Home") to his new version (the one with the "p"). When we asked for the more simplified URL after arguing, he just redirected all the "p" URLS to the PAGE NOT FOUND. However, remember, all the original URLs are now being redirected to the PAGE NOT FOUND as a result. The problems I see are these unless he redirects again: The new simplified URLS have to start from scratch to rank 2)We have duplicated content - two URLs with the same content Customers clicking products in the SERPs will currently find that they are being redirect to the 404 page. I understand that redirection has to occur but my questions are these: Is it ok to redirect twice with 301 - so old URL to the "p" version then to final simplified version. Will link juice be lost doing this twice? If he redirects from the original URLS to the final version missing out the "p" version, what should happen to the "p" version - they are currently indexed. Any help would be appreciated. Thanks Technical SEO | | AL123al0
- 
		
		
		
		
		
		Https redirect when certificate expired
 Hi, How do we 301 an https version of a domain to a page on another website when the security certificate has run out? We have 301 redirected the http version but IT stuck on how to do the expired https. Thanks Technical SEO | | Houses0
- 
		
		
		
		
		
		How do I fix the h1 tag?
 No More Than One H1 Tag Easy fix <dl> <dt>Number of H1s</dt> <dd>2</dd> <dt>Explanation</dt> <dd>Best practices for both SEO and accessibility require only a single H1 tag. The H1 is meant to be the page's headline, and thus, multiple H1s are confusing. Consider employing H2, H3 or CSS styles to achieve the same results with text visualization.</dd> <dt>Recommendation</dt> <dd>Remove multiple instances of the H1 tag, so that only one exists on the page.</dd> <dd>I get this error yet it does not tell me how to fix it. I'm not even sure what the H1 tag is? Technical SEO | | 678648631264
 </dd> </dl>0
- 
		
		
		
		
		
		200 Redirects for SEO instead of 301
 We are working with a company on re-platforming our website. On a call yesterday they outlined a strategy to use 200 redirects for our top keywords instead of 301s. I am not familiar with this type of redirect and was wondering if anyone could provide some more insight. Technical SEO | | EvergladesDirect0
 
			
		 
				
		 
			
		 
					
				 
					
				 
					
				 
					
				 
					
				 
					
				 
					
				