VHjD76rJPFUdrLp9aMufj6CAZXIPFT
Magento URL fixes

How to Perform URL Fixes in Adobe Commerce (Magento 2)?

4 min read By: Zenul Jinwala

4 February, 2025

URL-Fixes-in-Adobe-Commerce-Magento-2

Overview & Rationale

A Step-Wise Guide for Fixing Canonical & Redirect Issues for Large-Scale Product URLs in Magento 2 – Adobe Commerce for SEO

Many Magento 2 sites, especially large-scale eCommerce platforms, face URL inconsistencies where category-based product URLs (/brands/…/product.html) and direct product URLs (/product.html) exist simultaneously. When improperly managed, this leads to:

  • Google indexing the wrong version (e.g., /product.html instead of /brands/…/product.html).
  • SEO dilution, where ranking signals are split between duplicate URLs.
  • User confusion & inefficient crawling wasting Google’s crawl budget.

To correct this, we need to:

  1. Fix Canonical Tags to ensure category-based URLs are preferred.
  2. Implement Bulk 301 Redirects from /product.html to /brands/…/product.html to consolidate SEO signals.

Let’s now focus on the step-wise guide that is quick and easy to perform.

4 Steps to Fix Magento - Adobe Commerce URLs

Step 1: Global Canonical Tag Update

Ensure Canonical Tags Point to Category-Based URLs (/brands/…/product.html)

Magento is currently generating canonical tags pointing to /product.html, which is why Google is indexing the wrong versions. To fix this site-wide, update the canonical URL logic in Magento 2:

Modify the Canonical Tag Generation

  1. Go to:
    • Magento Admin → Stores → Configuration → Catalog → Catalog → Search Engine Optimization
    • Set “Use Canonical Link Meta Tag for Products” to NO (to prevent it from enforcing /product.html).
  2. Use a Custom Canonical URL for Products:
    • Modify catalog_product_view.xml (if necessary) or override Magento’s default logic.
    • Ensure the canonical URL dynamically includes the category path.

Custom Code Fix (If Needed)

If Magento is still enforcing /product.html as canonical, override it using default.xml:


<referenceBlock name="head.additional">

    <block class="Magento\Framework\View\Element\Template" name="custom.canonical" template="Magento_Theme::custom_canonical.phtml" />

</referenceBlock>

Then, create custom_canonical.phtml to output category-based canonicals dynamically:


<?php

$product = $block->getProduct();

$category = $block->getCurrentCategory();

if ($category) {

    $canonicalUrl = $block->getUrl($category->getUrlPath()) . $product->getUrlKey() . ".html";

} else {

    $canonicalUrl = $block->getUrl($product->getUrlKey() . ".html");

}

?>

<link rel="canonical" href="<?= $canonicalUrl ?>" />

This forces the canonical tag to include the category path when available.

Step 2: Bulk 301 Redirects from /product.html to /brands/…/product.html

Since Google has already indexed the shorter URLs (/product.html), we need to redirect them to the correct category-based URLs (/brands/…/product.html):

  • Preserve SEO value.
  • Ensure users always land on the correct version.
  • Prevent duplicate content issues.

🚀 Scalable Redirect Implementation

Given the large number of products (400,000+), we must handle redirects efficiently.

Option 1: Server-Side Redirects (Preferred for Large-Scale Sites)

Apache .htaccess Redirect (Efficient for Large Sites)


RewriteEngine On

RewriteCond %{REQUEST_URI} ^/([a-zA-Z0-9-]+)\.html$ [NC]

RewriteCond %{DOCUMENT_ROOT}/brands/*/%1.html -f

RewriteRule ^([a-zA-Z0-9-]+)\.html$ /brands/dmf-lighting/$1.html [R=301,L]
  • This dynamically redirects /product.html to /brands/…/product.html only if the correct file exists.
  • No need for 400,000 separate rules—this scales efficiently.

Nginx Redirects (Even Faster)


location ~* ^/([a-zA-Z0-9-]+)\.html$ {

    if (-f $document_root/brands/dmf-lighting/$1.html) {

        return 301 /brands/dmf-lighting/$1.html;

    }

}
  • This avoids checking every request against a massive list of URLs.
  • Redirects only if the category-based URL exists.

Option 2: Bulk Import Redirects via Magento Admin (Slower, But Alternative)

  1. Go to: Marketing → SEO & Search → URL Rewrites
  2. Bulk Upload 301 Redirects Using a CSV:
    • Export product URLs from the database.
    • Match them with their correct category-based URLs.
    • Upload a CSV to create 301 redirects.

Avoid using Magento’s database for all 400,000 redirects—it can slow down performance.

Step 3: Re-Crawl & Re-Index The Correct URLs

After fixing the canonical tags and implementing 301 redirects, we need to prompt Google to reprocess the URLs.

  1. Bulk Submit Correct URLs in Google Search Console
  1. Go to Search Console → URL Inspection
  2. Upload a Sitemap With Only Category-Based URLs (/brands/…/product.html)
  3. Request Re-indexing for the Main Product Pages
  1. Remove Old Indexed Short URLs (/product.html)
  1. Use Google Search Console → Removals Tool
  2. Temporarily Remove /product.html URLs From Google
    • This speeds up the switch to the correct URLs.

Step 4: Monitor SEO Impact & Search Console Reports

Wait 1-2 weeks and check:

  • Are /brands/…/product.html URLs getting indexed?
  • Are /product.html URLs disappearing?
  • Is Google following the 301 redirects?

Check Google Search Console:

  • Go to Coverage Report and check “Canonical Chosen by Google.”
  • Ensure that Google is now indexing the category-based URLs.

Final Summary

Fix Canonical Tags to point to /brands/…/product.html
301 Redirect /product.html/brands/…/product.html via Apache/Nginx rules
Submit the correct URLs in the Google Search Console
Remove old URLs from indexing to speed up reprocessing
Monitor search rankings to confirm Google has switched to the preferred URL structure

This structured approach ensures SEO best practices, improves rankings, and consolidates authority without overloading Magento’s database.

This step-wise guide is a useful reference for URL optimizations. However, for a more structured approach towards on-page SEO, a detailed analysis and audit by experts is needed. Enter Krish, an expert-led Digital Marketing agency specializing in Magento – Adobe Commerce, for all things organic and beyond. Connect with us today!

Canonical tag fixingMagento URL fixesURL fixes
Zenul Jinwala

As Director - Marketing, Zenul leads the marketing and branding at Krish. He brings with him an in-depth understanding of the evolving digital ecosystem and has a proven expertise and experience in strategic planning, market and competition analysis, creating and implementing client-centered, lead-gen and brand marketing campaigns. He has a heart for technology innovation and has been a keynote speaker on various platforms.

Trusted by leading brands

Ready to redefine digital experience?

Be it the Americas, EMEA, or APAC - our regional experts are available to offer solutions tailored to your needs.
Get in touch!

  • By submitting this form you agree with the terms and privacy policy of Krish.


    Let's Get Started


    • By submitting this form you agree with the terms and privacy policy of Krish

      Meet us at the !

      • By clicking “Submit”, you consent to allow us to send you communications.

        Talk to us!


        • By submitting this form you agree with the terms and privacy policy of Krish

          Schedule A Meeting


            • Schedule Date

            • 2 November3 November


          • By submitting this form you agree with the terms and privacy policy of Krish

            Schedule a Call


            • By submitting this form you agree with the terms and privacy policy of Krish

              Schedule a Call


              • By submitting this form you agree with the terms and privacy policy of Krish

                Schedule a Call


                • By submitting this form you agree with the terms and privacy policy of Krish

                  Schedule a Call


                  • By submitting this form you agree with the terms and privacy policy of Krish

                    Schedule a Call


                    • By submitting this form you agree with the terms and privacy policy of Krish

                      Schedule a Call


                      • By submitting this form you agree with the terms and privacy policy of Krish

                        Schedule a 30 Mins No-Obligation Consulting Session


                        • By submitting this form you agree with the terms and privacy policy of Krish

                          Schedule a 30 Mins No-Obligation Consulting Session


                          • By submitting this form you agree with the terms and privacy policy of Krish

                            Schedule a 30 Mins No-Obligation Consulting Session


                            • By submitting this form you agree with the terms and privacy policy of Krish

                              Schedule a 30 Mins No-Obligation Consulting Session


                              • By submitting this form you agree with the terms and privacy policy of Krish

                                Schedule a 30 Mins No-Obligation Consulting Session


                                • By submitting this form you agree with the terms and privacy policy of Krish

                                  Schedule a 30 Mins No-Obligation Consulting Session


                                  • By submitting this form you agree with the terms and privacy policy of Krish

                                    Schedule a 30 Mins No-Obligation Consulting Session


                                    • By submitting this form you agree with the terms and privacy policy of Krish

                                      Schedule a 30 Mins No-Obligation Consulting Session


                                      • By submitting this form you agree with the terms and privacy policy of Krish

                                        Let's Get Started


                                        • By submitting this form you agree with the terms and privacy policy of Krish.

                                          Schedule A Demo

                                            • Select Accelerator Type

                                            • B2BB2CMarketplace


                                          • By clicking “Submit”, you consent to allow us to send you communications.

                                              Download Corporate Profile

                                              Please fill out the form below to download.

                                              • By submitting this form you agree with the terms and privacy policy of Krish.

                                              Let's Talk


                                              • By clicking “Submit”, you consent to allow us to send you communications.

                                                Let's Talk


                                                • By clicking “Submit”, you consent to allow us to send you communications.

                                                  Adobe Commerce Feature List

                                                    Please fill out the form below to download the feature list.


                                                    By submitting this form you agree with the terms and privacy policy of Krish.

                                                  • Let's Talk Growth



                                                    • By submitting this form you agree with the terms and privacy policy of Krish

                                                      commercetools Feature List

                                                        Please fill out the form below to download the feature list.


                                                        By submitting this form you agree with the terms and privacy policy of Krish.

                                                      • Let's Talk Growth!


                                                        • By submitting this form you agree with the terms and privacy policy of Krish

                                                          Claim Your Audit Now!


                                                          • By submitting this form you agree with the terms and privacy policy of Krish

                                                            Claim Your Audit Now!


                                                            • By submitting this form you agree with the terms and privacy policy of Krish.

                                                              Let's Get Started

                                                              • By submitting this form you agree with the terms and privacy policy of Krish.

                                                                Unlock the Full Potential of Magento.
                                                                Talk to our eCommerce expert today!


                                                                • By submitting this form you agree with the terms and privacy policy of Krish.

                                                                  Migrate to Magento to Experience Limitless Commerce. Talk to Our eCommerce Experts Today!


                                                                  • By submitting this form you agree with the terms and privacy policy of Krish.

                                                                    Get Certified Magento Experts for Your Adobe Commerce Support Needs. Talk to Our eCommerce Experts Today!


                                                                    • By submitting this form you agree with the terms and privacy policy of Krish.

                                                                      Scale High with Award-winning Adobe Commerce Gold Solution Partner Agency. Talk to Our eCommerce Experts Today!


                                                                      • By submitting this form you agree with the terms and privacy policy of Krish.

                                                                        Scale High with Award-winning Magento Solution Partner Agency. Talk to Our eCommerce Experts Today!


                                                                        • By submitting this form you agree with the terms and privacy policy of Krish.