Rewrite URL when migrating an eCommerce website to Magento

December 16, 2019 in Magento

Rewrite URL when migrating an eCommerce website to Magento
I recently worked on an interesting project for migrating from an old ASP.NET eCommerce site to the latest version of Magento 2 open source (2.1.9). A common request is, they want to redirect permanently their old product URL to a new one to the new URL under Magento 2 URL structure. I suppose that they need to redirect product with old URL:
/productdetail.aspx?ID=99 to /this-is-a-migrated-magento-product-url.html
  You may think that it is just simply adding custom URL redirection in Magento URL Rewrite management like the picture below But doing so would bring this URL  to a 404 page. I did a simple trick with .htaccess
RewriteCond %{REQUEST_URI}  ^/productdetail\.aspx$
RewriteCond %{QUERY_STRING} ^ID=([0-9]*)$
RewriteRule ^(.*)$ [R=301,L]
  and then, I will add this custom url to magento backend   After that, when visiting It will be redirected to I really hope my quick tip will save you guys time for finding a solution to saving the website SEO ranking after migration and avoiding users with annoying 404 errors.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.