3

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:

domain.com/catalog/product/view/id/2221/name-of-the-product

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

domain.com/catalog/product/view/id/5856/s/name-of-the-product/category/899

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

domain.com/name-of-the-product

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. – Michael Poppinger May 8 at 12:06
  • @MichaelPoppinger you are right. – Kingshuk Deb May 20 at 6:49
1

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

and

  • 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 Apr 7 '17 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.. – Himmat Paliwal Apr 7 '17 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 Apr 7 '17 at 10:04
  • Run the commands at your root directory in command prompt. I have updated my post with commands. – Himmat Paliwal Apr 7 '17 at 10:08
  • Verify if mod_rewrite is enable on server. You can do that by checking phpinfo of your website. – Himmat Paliwal Apr 7 '17 at 10:20
0

Please you this module to regenerate products URL...

https://github.com/Iazel/magento2-regenurl

  • Can you expand why this is necessary? Readme is quite unclear, is there same code which is used for reindex catalog url? Thanks – FireBear Jun 22 '17 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. – Abhinav Singh Jun 24 '17 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 – CrackIt Apr 13 at 22:10
0

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.

0

Use Extensions “Regenerate Url rewrites”

https://github.com/olegkoval/magento2-regenerate_url_rewrites

After install run below command

bin/magento ok:urlrewrites:regenerate

it is working for me.

Hope it will help.

0

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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