Skip to content

Why aren’t Magento 2 URL rewrites working as I’d expect?

Since deploying a Magento 2 website we’ve had trouble with URL rewrites. The default URL used by our products is (example)
mysite/catalog/product/view/id/50146/s/my_product/my_category/2/
This is not what I want to see and does not match the URL Key set in admin for the product. I have canonicals set to ‘yes’ for both products and categories.

I have the ‘Create Permanent Redirect For Old URL’ option selected by default but if I import new product URL keys using a 3rd party extension rewrites are not created.

If I use a third party module to regenerate the rewrites (elgentos) the url keys are ignored. The result is that the product URLs are long and unfriendly, as in the above example.

If I manually change the URL key and save the product then URL rewrites are added to the table but most of the rewrites have type set to ‘No’ where I would expect 301.

Oddly this doesn’t apply to all products but I can’t find a valid reason. The main problem is that previously indexed urls are no longer accessible to Google and site visitors unless I change each one manually (there are over 40K products). The other issue is that Google is attempting to index the long, non canonical URL, including pattern /catalog/, this path blocked by our robots.txt. I could remove /catalog/ from robots but I don’t want this URL to be indexed, I want it to be corrected and friendly for Google and site visitors.

  1. Any ideas why my import of new URL keys is not creating rewrites for the old URL?
  2. Why are manual url key changes resulting in rewrites with type ‘No’ surely these are of no use?
  3. Why isn’t Magento using URL keys to create canonical URLs?
  4. Why are URL keys ignored when recreating the rewrites table?
    Thanks