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:
To correct this, we need to:
Let’s now focus on the step-wise guide that is quick and easy to perform.
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
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.
Since Google has already indexed the shorter URLs (/product.html), we need to redirect them to the correct category-based URLs (/brands/…/product.html):
🚀 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]
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;
}
}
Option 2: Bulk Import Redirects via Magento Admin (Slower, But Alternative)
Avoid using Magento’s database for all 400,000 redirects—it can slow down performance.
After fixing the canonical tags and implementing 301 redirects, we need to prompt Google to reprocess the URLs.
Wait 1-2 weeks and check:
Check Google Search Console:
✔ 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!
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.
2 September, 2025 Anyone running a business knows the drill: emails pile up, data needs updating across five different systems, and someone always seems to be waiting for approval on something. These mundane tasks eat up hours each day, pulling teams away from work that actually grows the company. AI workflow automation changes this reality. Instead of manually routing customer inquiries or updating product information everywhere, intelligent systems handle these tasks automatically. Recent data shows 60% of organizations see ROI within 12 months, with productivity jumping 25-30% in automated processes. The difference between traditional automation and AI-powered workflows? Smart adaptation. While old-school automation follows rigid if-then rules, AI workflows learn patterns, make contextual decisions, and adjust to changing situations. Think of it as having a highly efficient assistant who never sleeps and gets better at the job over time.
Never miss any post, stay tuned!