We are having a strange problem in our Magento 2 webshop. Our webshop has different ways of generating the product url. So some of our products just show the product url as it should be /name-of-the-product and others show it with the following structure:


And then we have a third way and that is that it includes the category id in the url like:


We would all products like to be just with the name of the product so:


We tried setting up the search engine optimization settings by configuration / catalog / catalog as shown in the first answer and shown in the image blow, but this did not work:

enter image description here

We also tried setting up the search engine settings by configuration / general / web / Search engine optimization as shown in the printscreen below, but this also does not work.

enter image description here

You can see what is happening on https://www.loungeset.nl/accessoires/tuinmeubelhoes. If you scroll a bit down to for instance to AeroCover bbq hoes ø52cm - antraciet you see what is happening

Has anyone a idea how this comes?

  • @KingshukDeb the question is about Magento 2.x, not Magento 1.x, so there is no url_rewrite index anymore and the table is now called url_rewrite.
    – michi-p
    Commented May 8, 2019 at 12:06
  • @MichaelPoppinger you are right. Commented May 20, 2019 at 6:49

5 Answers 5


In case anyone else has this issue, I had the same and the above didn't work for me either. The issue is caused by duplicate url keys being generated from products with the same name. I used this module https://www.cadence-labs.com/2017/11/magento-2-fix-duplicate-url-key-for-categories-and-products/ to change all of the duplicate url keys and then ran the olegkoval regenerate url rewrites module afterwards and this fixed the issue.

Hope this helps someone else who is facing the same problem!

  • The duplicate URL keys problem has solved it for a few 2.2.x installations I work with. Not dangerous to run the extension even if there are no duplicates, just give it a go!
    – Sven
    Commented Nov 22, 2019 at 20:14
  • i run this nightly with cron and it does the trick. Commented May 25, 2021 at 22:36

You need to enable the url rewrite via store configuration:

To enable Url rewrites Login in to the admin panel,

  1. on the side bar click stores.
  2. Choose configuration. On left panel
  3. expand General and select Web from the list.

The configuration window will open, click on Search Engine Optimization and look for "Use Web Server Rewrites" and Set it to yes. Also run below listed commands from your root directory in command prompt after this settings:

  • php bin/magento cache:flush


  • php bin/magento indexer:reindex

Also verify if .htaccess file is available at your root directory and mod_rewrite is enable on your server.

  • Hi Himmat, thank you for your reply and we have this enabled, I will put a printscreen in the question, so this does not look to help. See my question to see the settings, any other ideas?
    – Coen
    Commented Apr 7, 2017 at 9:59
  • Please see my updated post now and let me know if it helps.. Don't forget to flush configuration cache and run indexer:reindex command after doing that.. Commented Apr 7, 2017 at 10:00
  • thanks for your quick reply and also tried that one, both settings were already setup correctly and now also put that setting in the question so you can see what it has. Are there other settings that I could try?
    – Coen
    Commented Apr 7, 2017 at 10:04
  • Run the commands at your root directory in command prompt. I have updated my post with commands. Commented Apr 7, 2017 at 10:08
  • Verify if mod_rewrite is enable on server. You can do that by checking phpinfo of your website. Commented Apr 7, 2017 at 10:20

Use Extensions “Regenerate Url rewrites”


After install run below command

bin/magento ok:urlrewrites:regenerate

it is working for me.

Hope it will help.


Please you this module to regenerate products URL...


  • 1
    Can you expand why this is necessary? Readme is quite unclear, is there same code which is used for reindex catalog url? Thanks
    – FireBear
    Commented Jun 22, 2017 at 13:54
  • Please note many time magneto doesn't generate URL due to which it take default URL (without rewrite) to overcome the issue I uses this extension and it work for me. Commented Jun 24, 2017 at 9:46
  • I tried this module once and some of my products got vanished from the store and database then I had to add them manually. So please take database or products backup before using any module and regenerating products URL's Commented Apr 13, 2019 at 22:10

The URL for that particular product might not exist in the URL Rewrites of Magento, the way I solved the issue was by manually creating a product URL rewrite for each category manually. It's a long process my friend, otherwise use an extension.

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.