4

I cannot figure out what settings would prevent this from happening. Also cannot figure out how to fix the urls that have been set this way already. Thanks Sam

2
  • For reference: the question has been asked already but does not have an accepted answer yet at magento.stackexchange.com/q/121096/243 - did you also migrate products from Magento 1? Commented Sep 10, 2016 at 18:57
  • I IMPORTED the products - but not from a magento site. Also - good point - only the imported products have this double suffix problem. Also it seems products that are in multiple categories has this problem. I can go into the table and clean once - but if I dont know why it is happening it will happen again.
    – samreg
    Commented Sep 11, 2016 at 23:57

3 Answers 3

5

We fixed the URL's like this:

  1. Remove all product related rewrites from url_rewrite table
  2. Mass update all products in admin (select all, update, set website as default)
  3. If problem still exists, run this MySQL command:

UPDATE url_rewrite SET request_path = REPLACE(request_path, '.html.html', '.html') WHERE url_rewrite.request_path like '%html.html';

Then clear the caches.

2
  • i would prefere it with a where condition like WHERE url_rewrite.request_path like '%html.html'
    – ZFNerd
    Commented Oct 4, 2018 at 7:14
  • @ZFNerd I'm sure your solution is better as I'm no MySQL master... If you could share the whole command that would be great.
    – Webninja
    Commented Oct 5, 2018 at 7:17
2

This is more of an addition to @Webninja's answer, as his steps might solve the issue for others. Consider this a work-around and not a fix. Since it's a known bug in Magento 2.

In our case the mass update caused the double suffix to re-appear after saving a product or category, so the URLs were generated incorrectly. Our products were also imported from a Magento 1.x install.

Also the UPDATE-query mentioned in his post didn't work, due to duplicate entry errors.

So, what I did was the following:

  1. Remove all product related rewrites from url_rewrite table (DELETE FROM url_rewrite WHERE entity_type = 'product';)
  2. Remove the Product URL suffix (.html, in my case) and leave the field blank in stores > configuration > catalog > catalog > search engine optimization;
  3. Mass update all products in admin (select all, update attribute, check the box underneath 'Add product to website')
  4. In case mass update gives errors ('something' already exists) you can also save each main category (not root, one or two levels (depending on your setup) underneath) seperately. The URLs will also be regenerated then.

Now the URLs are correctly generated at each save of a product or category.

0
0

This is happening because of url rewrite management module.

For more information, go to Magento 2 Admin -> Marketing -> SEO & Search -> URL Rewrites. you can change Request path.

You can find the module at

/vendor/magento/module-catalog-url-rewrite/
1
  • Where would I find the request path ? I can see Product url suffix, cat url suffix, use cats path for product urls (mine is NO), Create permanent redirect for urls (Mine YES). Canonical Links ? Mine Both NO
    – samreg
    Commented Sep 10, 2016 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.