I have recently created 2 additional store view on magento 2 store. Now the url of category and Products are not for those stores is not proper

Eg: http://example.com/catalog/category/view/s/pouches/id/20/ which is suppose to be http://example.com/accessories/pouches.html

Now when I save each product and category one by one it regenerate url rewrite for that product or category.

But there are lots of products and category.

So is there any way to regenerate URL rewrite

as in Magento 1.x it can be done via reindexing.

  • In Magento 2 url rewrite module does not use Indexer to create rewrites. Rewrite is generated in process of save/import of product/categories/cms pages. So you might need to go the programmatically way of loading and saving the categories
    – mp196
    Commented Jan 11, 2017 at 7:09
  • can you suggest me some reference to create script to do so. Commented Jan 11, 2017 at 7:21
  • You need to Re indexing again. Commented Jan 11, 2017 at 8:02
  • I have already try indexing, There is not URL Rewrite Index in Magento 2. So it do not worked. I have reindex now again, its not working Commented Jan 11, 2017 at 8:42
  • 2
    For products what you try is select all of them from grid, And select update attributes and in websites tab select the website (though products are already assigned to the same website) This shall resave the product and might regenerate url rewrites.
    – mp196
    Commented Jan 11, 2017 at 8:49

10 Answers 10


This module is been deprecated you can use this module instead

Download Using Composer;

composer require elgentos/regenerate-catalog-urls

php bin/magento setup:upgrade

Regenerate url for all products and the global store

php bin/magento regenerate:product:url

Regenerate url for products with id (1, 2, 3, 4) for store 1

php bin/magento regenerate:product:url -s1 1 2 3 4

  • that module is buggy, but still can help in some cases.
    – Gediminas
    Commented Jun 26, 2017 at 13:36
  • Yes, and it will be helpful for us to use those methods to trigger product url rewrites. Commented Jun 27, 2017 at 8:15
  • 2
    Currently, doesn't work in 2.1.9 ... Commented Oct 17, 2017 at 20:55
  • @Spyrule I'm on 2.1.9 and experienced issues. However after logging my issue, someone pointed me to this pull request that hasnt been approved yet works a charm for me: github.com/Iazel/magento2-regenurl/pull/21/commits/… Commented Oct 18, 2017 at 14:45
  • @Gerdiminas what bugs do you know about?
    – harri
    Commented Nov 9, 2017 at 16:38

You can use Regenerate a Url rewrites extension (it allow to regenerate a Url rewrites of products and categories) .

To re-generate all Url rewrites of the categories/products in all stores (it support a multistores) run:

$> bin/magento ok:urlrewrites:regenerate

To regenerate Url rewrites in the specific store view (e.g.: store view id is "2"):

$> bin/magento ok:urlrewrites:regenerate 2
  • 1
    This extension working perfectly for me. Thanks for your extension.
    – mapaladiya
    Commented Dec 20, 2017 at 2:09
  • it works very good! thx!
    – LucScu
    Commented Feb 2, 2018 at 16:27
  • Does this delete the old rewrites? Commented Feb 14, 2018 at 18:46
  • 1
    Is it still working? It doesn't for me.
    – Kirby
    Commented Nov 7, 2018 at 14:43
  • 1
    @OlegKoval I have installed version 1.3.1 but still it doesn't work for me. So what is the issue behind this? Commented Dec 18, 2018 at 11:28

There is actually an easy way to fix this without a lot of trouble. For the TL:DR people, the bold parts are relevant.

One thing to check first; if you have multiple store views, go into the product and switch the view to particular view. Scroll down and make sure the URL-Key is set to "Use Default Value". If that isn't checked, it will never generate. I think this can happen when you import M1 products. I had 200+ products that needed touched up.

This fix also helps if you do the trick where you switch your store to a different root and back, which cleans out everything. Including your custom ones. And it can finish with nothing but the category URL's. Not sure why the URL generation for products fails completely but I think it's because Magento is trying to make too many links in one operation which fails.

So give this a shot. Open the URL rewrite window and note the number of entries. This let's you know if it works.

Go into a first level category (it doesn't work on default because is doesn't have a URL key). Scroll down to Search Engine Optimization / URL-Key. Add an X to the end of the key. Uncheck the "Create Permanent Redirect for old URL", it only adds more work to the operation. Save your category.

Repeat the operation and remove the X, again uncheck the "Create Permanent Redirect for old URL", because you don't need those old URL's clogging up the table. Save again.

Refresh the URL rewrite page and you should see a new number, and shiny new URL's.

Repeat as needed.

FYI really big categories may time out. So in those cases, do the smaller sub-categories by themselves. On my server that threshold is about 400 entries.

Magento is smart enough to make the links for the category above your sub-categories. It is also smart enough that when it see's a product in another category, it builds the links for there too.

Took me a while to figure out why I was seeing fewer and fewer links added as I went down the category list. It was because a majority of products were already in the table and just the stragglers that hadn't appears before remained.

  • man, i bow to you. That is exactly what happen to us, our admin accidentally created category outside of root, and then it broke all store product URL's. After re/saving with different url-key it instantly fixed the issue. No need for the custom module or any code modification. Thank you. Commented Mar 11, 2020 at 4:15
  • @Brokentusk, god bless you, bro! You saved me. Commented Dec 10, 2020 at 19:53
  • UR rewrites work for me I changed the categories of the demo products. I should have added new ones. Now the rewrite has worked for all categories except the category that has a Mega Menu. Category is Mac>Laptops(sub category) in the menu mac appears as /shop.html and laptops as shop/men.html I tried changing the mega menu to another category. The menu changes to normal but the URLS were the same as the demo products. URL rewrites work in 2.3.5-p but for some reason won't work for these products. Reindexed every re compile but didn't change anything
    – rawraj
    Commented Dec 15, 2020 at 20:12
  • great answer - highly recommended over plugins as this is fixed via Magento code itself. only caution would be when fixing this with a large product catalog as it can time out Commented Apr 8 at 1:49

In update to @mahendra Jella's answer, Try this branch of the same extension: https://github.com/PascalBrouwers/magento2-regenurl/tree/feature/generate_category

This one can regenerate URLs for categories too.

The command goes as follows:

php bin/magento iazel:regenurl
# Regenrate Category URL keys >
php bin/magento iazel:regenerate_urls
  • This extension worked beautifully for me in 2.1.9. Helped identify duplicate url products by ID as well (albeit, a minor update to list the sku would be useful). Commented Oct 17, 2017 at 22:34
  • This extension not work for me magento 2.2.9
    – jruzafa
    Commented Aug 30, 2019 at 7:58

All you need to do in order to regenerate rewrites is to initiate a rewrite. Go to a category or product and change its url in the SEO section of the product/category by adding a "a-" to the front of it. For example:

Url = "product-name" New Url = "a-product-name"

This will trigger the rewrite and redo all other rewrites.

  • 3
    This only works if you have a handful of rewrites. With more than 100 products stuck on the old URL this is no feasible solution.
    – Jacques
    Commented Oct 2, 2019 at 14:22

So, I had this issue for products and fixed this by using the mass update feature to remove all products from the store and then re-adding them. I didn't have very many categories, so I just went in and re-saved them.

Overall, I think avoiding the ole' truncate and regenerate tactic we did in Magento 1 is probably best. If your product rewrites look wrong, just do what I posted above and that should correct them.


As per I know Magento 2 does not provide this feature, but I am using this extension


from this I can able to regenerate category and all product url.

Note: I am not promoting the extension hence I am using this extension and its quite useful for me.


Unfortunately none of these extensions/modules have worked for me. I have about 4000 products and moving from Magento to 2.2.2. I used the Data Migration tool and it worked like a charm, other than this issue.

Some of my products have url keys and some do not. I only have one store which is the frustrating part. It looks like Magento considers the admin a store.

The only thing that has worked for me was importing the products with 'replace' option. And for SEO purposes I don't want to change the url's of my products, not even if it's just adding a number after.

I'm going to try deleting the url rewrites for products only.


I ran into a similar problem. In Magento 1, it was possible to truncate the url rewrite table and reindex. Magento 2 does not have a url rewrite indexer, so this is not an option.

Many suggest the Iazel extension. I went with the extension by Olgeg Koval, and it worked beautifully. Running Magento 2.2, it deleted all existing url rewrites and regenerated them for all store views. Zero problems.


In order to regenerate the URL rewrites in Magento 2,

  • Sign-in to the backend.
  • Navigate to Stores -> Configuration -> General -> Web
  • Expand the Search Engine Optimization section
  • Set the Use Web Server Rewrites to ‘Yes’.
  • Click the Save Config button to save your settings.

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.