How to Regenerate URL Rewrites in Magento 2

- E-Commerce, Magento 2

Regenerate URL Rewrites Magento 2

In the following article, we shed light on Magento 2 URL rewrites regeneration. Many users report issues working with them. Luckily, the community offers several ways to solve them. If you import products, but the corresponding URL rewrites are not regenerated automatically, you’ve come to the right place. In this article, we explain how to regenerate URL rewrites. Furthermore, you will discover how to import products, avoiding this issue. 


Regenerate URL Rewrites in Magento 2

Although there is an indexer in Magento 1.x which successfully regenerates URL rewrites automatically, Magento 2 doesn’t offer the same solution. Why was it removed? The answer is simple – performance. The more products you have, the more time it is necessary to import them to your 1.x store because of the reindexer. Therefore, to improve the platform’s performance, that handy feature has been removed from Magento 2, causing new issues. 

A deeplink for a product has the following appearance:

Unfortunately, this link is not suitable for good SEO. However, the URL rewrite perfectly solves the problem. Instead of numbers, that are not usable for a search machine, you use your category and product names. Thus, the link mentioned above can be replaced with a more SEO-friendly one:

Magento 1.x did that to all URLs automatically, making the entire e-commerce website more reliable from the perspective of search engines. Magento 2 do not that automatically. Thus, you have to regenerate URL rewrites manually in Magento 2. 

Note that they are computed in the case of specific manual actions. For instance, you create and save categories and products in the Magento 2 backend. In the case of import processes, you have to perform lots of unnecessary additional work manually, but there is always a better way to achieve this goal.


The solution proposed in the Magento2 Blog is a Magento 2 URL rewrites regeneration module by Lazel. By the time of writing this article, the developer behind this solution posted on the module’s page that he no longer uses Magento, so his tool might be outdated. Instead, he proposes to utilize the module’s fork – regenerate-catalog-urls by elgentos.

The new extension adds console commands that enable URL rewrites regeneration in Magento 2 creating:

  • a product rewrite URL based on its url path; 
  • a category rewrite URL based on its url path; 
  • a category URL path based on its URL key and its parent categories.

The initial module lets you call regeneration by code or from the command line. According to Magento2 Blog, it is better to do it by code in your importer module:

The snippet above enables you to regenerate URL rewrites in  \Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator(productUrlRewriteGenerator). Inject it into your model. Note that there is a possibility to replace the generated URL rewrite by \Magento\UrlRewrite\Model\UrlPersistInterface(urlPersist). 

The module lets you run everything in a loop for all products or implement an individual approach for every single product.

As for exact URL rewrites, they are available in the url_rewrite table in your database just like in case of Magento 1.

URL Rewrite Regeneration Magento 2 Extensions

You can also use one of the following alternative URL rewrites regeneration extensions.

Magento 2 Module by Oleg Koval

There is also an alternative solution mentioned in Magento2 Blog – Magento 2 Module by Oleg Koval. The extension lets you regenerate all your Magento 2 URL rewrites for products and categories with the following command only:

URL Rewrite Regeneration by T.H. Lassche Webdevelopment

Regenerate URL Rewrites Magento 2

As for URL Rewrite Regeneration by T.H. Lassche Webdevelopment, this Magento 2 extension simplifies the process of product and category URL rewrites regeneration as well. The tool provides you with the ability to build an SEO friendly URL structure.

The only thing you need to execute is the following command that looks similar to the one we’ve mentioned above:

This command iterates all products and generates all URL rewrites. Note that multiple storefronts are supported. Furthermore, the extension supports all Magento SEO settings. 

It is also worth mentioning that you have two options to regenerate category URL rewrites in Magento 2:

  • run the command from the command line;
  • use cron to create a schedule. 

Note that the module doesn’t change any valuable product data. It only adds SEO-friendly URLs. For further information, follow this link: URL Rewrite Regeneration Extension for Magento 2.

URL Rewrite Regeneration with no Headaches

Regenerate URL Rewrites Magento 2

But there is a better way to avoid the URL rewrite issues. You need to improve the default data import solution. We recommend you to replace it with the Improved Import & Export Magento 2 extension. Our module lets you import and export URL rewrites in Magento 2 along with products.

The bigger your product catalog is – the more URL rewrites you have. Even a small e-commerce website contains thousands of URL rewrites. Consequently, you need a plethora of time to recreate them manually on a new store.

Of course, it is also possible to install one of the modules we’ve just mentioned, enabling the missing functionality in Magento 2. However, our solution not only adds the ability to import and export URL rewrites to/from Magento 2, but it also provides dozens of other vital features the platform lacks by default. You can discover how to import and export URL rewrites in this article: How to Import and Export URL Rewrites in Magento 2.

Other Features

Regenerate URL Rewrites Magento 2

Now, let’s take a look at other features of the Improved Import & Export extension that make it better than other solutions designed to regenerate URL rewrites.

Automated Import & Export

Our module lets you automate URL rewrites import and export as well as other data transfers via schedules or event-based triggers. 


The Improved Import & Export Magento 2 extension uses cron, allowing you to create any custom schedules of updates. At the same time, you can select one of the predefined values which are customizable as well. However, import and export jobs with no schedules are another opportunity provided by our module. Also, note that it is possible to launch every scheduled profile whenever you want. As for the configuration process, it is as simple as the following gif illustrates: 

Regenerate URL Rewrites Magento 2


Alternatively, the Improved Import & Export Magento 2 extension provides the ability to create event-based triggers. Although they won’t help you with URL rewrites regeneration, it is a quite handy feature for other import and export processes. For instance, you can transfer order data to an ERP system every time a new order is placed automatically. Follow the link below for more information regarding triggers: How to Run Magento 2 Import or Export After Specific System Event or Process.

Advanced Mapping Features

Advanced mapping opportunities is another great feature that does our module better than proposed solutions. When you import URL rewrites from Magento 1 or other external systems, our module lets you replace third-party attributes with ones used in Magento 2 to enable the import procedure. There is no need to do anything in data files. Let’s find out what opportunities are under your disposal.

Mapping Presets

Mapping presets introduce the most straightforward way of importing/exporting any data with the Improved Import & Export extension. The mechanism behind them is quite intuitive: you select a preset of a third-party system you are going to connect to, and the module replaces all the unsupported attributes automatically. Take a look at the following gif image to see how simple this process is: 

Regenerate URL Rewrites Magento 2

Matching Interface

Alternatively, you can match attributes manually in a corresponding section of an import or export profile. Select a third-party value and specify an internal one in front of it. You can also add a default attribute value which is provided to all items related to the attribute. You can see the illustration of this feature below: 

Regenerate URL Rewrites Magento 2

Attribute Values Mapping

In addition to attributes, the Improved Import & Export Magento 2 extension provides the ability to map their values. The algorithm is the same as the one described above. For more details, read this article: Attribute Values Mapping.

Attribute Values Editing

If the previous feature is not enough, our module lets you edit attribute values in bulk. The Improved Import & Export extension supports the following commands: 

  • Add a prefix to multiple attribute values;
  • Add a suffix to numerous attribute values;
  • Split various attribute values;
  • Merge many attribute values.

You can combine them and create conditions increasing the efficiency of the applied changes. Check this article for further information: How to Modify Attribute Values During Import and Export in Magento 2.

Category Mapping

You may not use category mapping in the URL rewrites import, but it dramatically affects related product data transfers. Our module lets you match external categories to ones used internally, reducing the number of difficulties that usually occur when products are transferred from other platforms to Magento 2. The Improved Import & Export module allows mapping external product categories to ones used in your catalog as follows:

Regenerate URL Rewrites Magento 2

To create new categories right in the import job, choose a parent category, and specify a new one that will be generated automatically. You can find more information about this feature here: Category Mapping.

Attributes On The Fly

And if a data file provided from an external system lacks attributes, the Improved Import & Export Magento 2 extension lets you create them on the fly via the following general form:


The feature is described here in more detail: Product attributes import.

Extended Connectivity Options

Another fundamental difference between Improved Import & Export and the default data transfer tool of Magento 2 or even third-party solutions is the ability to work with numerous file sources.  

Multiple File Standards

Firstly, our module supports various file standards. In addition to the default CSV, it also works with  XML, JSON, ODS, and Excel. The module also works with file archives! 

Multiple File Sources

Support for numerous sources of data files is another benefit of the Improved Import & Export Magento 2 extension. Our module lets you import URL rewrites from:

  • FTP/SFTP. Transfer data files using a local or remote server.
  • Dropbox. Use a Dropbox account to establish a connection between the two systems. Alternatively, you can rely on Box, OneDrive, Google Drive, iCloud, and Amazon Drive.
  • URL. A direct URL can be used to import a data file as well.

Regenerate URL Rewrites Magento 2

Alternative Ways of Import & Export

Note that the following alternative ways of import and export are not represented in Magento 2 by default. However, our module not only enables them but also makes the corresponding data transfers intuitive and straightforward.

The Improved Import & Export extension provides the ability to leverage REST, SOAP, and GraphQL to create API connection with external systems. For instance, you can transfer data between your store and ERPs, accounting platforms, CRMs, etc. Note that all API connections support other extension’s features so that you can leverage mapping, schedules, and attributes on the fly while transferring data via API.

It is also possible to leverage a bunch of intermediary services. You can rely on Google Sheets, Office 365 Excel, and Zoho Sheet, transferring data to your e-commerce store. The following image shows how to use Google Sheets to move data to Magento 2:

Regenerate URL Rewrites Magento 2

And of course, the Improved Import & Export extension opens completely new possibilities with support for WSDL and WADL.

The video below displays other details of our extension:


As you can see, the Magento 2 ecosystem offers multiple ways to enable URL rewrites regeneration in Magento 2. You can use more complex command-based solutions or leverage extensions that add the missing functionality right to the backend interface. The easiest way is to install our module. To do that, follow the link below:

Get Improved Import & Export Magento 2 Extension