How to Import and Export URL Rewrites in Magento 2

Magento 2 import URL Rewrites

This article discusses a significant point of every migration between e-commerce stores – the Magento 2 import of URL rewrites. Below, we describe how to import and export URL rewrites in Magento 2. Unfortunately, your e-commerce storefront doesn’t let you perform this data exchange by default. The import and export capabilities of Magento 2 are fairly limited and lack support for numerous entities, including Magento 2 URL rewrites. However, you can address the existing data sync problems with the help of third-party services, such as the Improved Import & Export Magento 2 extension. In the blog post below, you will learn how to use the extension to import and export URL rewrites between Magento 2 websites or from beyond the ecosystem. At the same time, we shed light on the URL Rewrites Magento 2 sample import and export table, explaining its attributes. You will also find a detailed description of the Improved Import & Export solution since it delivers lots of opportunities, in addition, to support for URL rewrites. 

What Are Magento 2 URL Rewrites?

URL rewriting is a useful technique that can help you transform complicated or unintelligible basic URLs into ones that are more comprehensible to both your customers and search engines. So, Magento 2 URL rewrites are just more user- and SEO-friendly URLs for your store pages.

Magento 2 offers a URL rewrite tool that lets you change any URL associated with a product, category, or CMS page, making it better. It removes words from URLs that have no value to search engines or customers and has no impact on performance or site rank. A URL without a rewrite looks as follows: http://www.yourwebsite.com/magento/index.php/storeview/url-identifier.

After applying the default Magento 2 URL rewrite it changes as follows: http://www.yourwebsite.com/magento/storeview/url-identifier.

As you can see, index.php is not available in the new URL since it is associated with a zero value for both customers and search engines.

When a Magento 2 URL rewrite goes into effect, all links that point to the initial URL are redirected to the new address. So, what are redirects then?

Magento 2 URL Rewrites & Redirects: Know The Difference

Although the terms rewrite and redirect are often used as synonyms, they possess slightly different meanings that refer to distinct processes:

  • A Magento 2 URL rewrite alters the appearance of URLs.
  • A Magento 2 URL redirect, on the other hand, updates URLs stored on the server either temporarily or permanently.

So, you can leverage Magento 2 URL rewrites and redirects to change URL keys of product, category, or CMS pages, preserving their existing links. Why is it necessary?

The Purpose of URL Rewrites

Well, you can use URL rewrites in Magento 2 to add high-value keywords to page URLs. The main goal of this procedure is to enhance your SEO. Search engines get an extra hint on the content you share on your store pages. As a result, you get a better index.

Another purpose of Magento 2 URL rewrites is that you can use them to create additional URLs for temporary seasonal changes. At the same time, they are also good for permanent changes.

Although you can create rewrites for any valid path, Magento 2 always references products and categories by their ID. So, it doesn’t matter how often you change the URLs (in fact, it matters how often you do that: because frequent changes may negatively affect your page ranking), the corresponding IDs remain the same.

For instance, this is a system URL that incorporates a product ID: http://www.yourwebsite.com/catalog/category/id/1. Let’s suppose that the original URL looks as follows: http://www.yourwebsite.com/category-name/page-name.html. However, you can use the Magento 2 URL rewrite feature to replace it with something more user-friendly: http://www.yourwebsite.com/new-product-url-that-is-more-suitable-for-both-customers-and-search-engines.html.

 

How to Enable URL Rewrites in Magento 2?

Follow these steps to enable URL rewrites in Magento 2:

  1. Go to Admin -> Stores -> Settings -> Configuration.
  2. In the left panel, expand General and choose Web.
  3. Proceed to the Search Engine Optimization section.
  4. Enable the Use Web Server Rewrites feature.
  5. Don’t forget to save the configuration.

magento 2 url rewrites configuration

Next, you may need to update URL rewrites for multiple products on your Magento 2 website:

  1. Go to Admin -> Catalog -> Products.
  2. Select all of the products you wish to update.
  3. Click on Actions and choose Update attributes.
    update magento 2 url rewrites for products: select products
  4. Choose the Websites tab under PRODUCTS INFORMATION.
  5. Select all websites for which you want to restore URL rewrites in the Add Product To Websites section.
  6. Click Save to regenerate URL rewrites for the selected products on the selected websites.
    Choose websites to update magento 2 url rewrites

Magento 2 Import: URL Rewrites

Even medium e-commerce websites could have hundreds or thousands of products and, consequently, URL rewrites. Therefore, you need a plethora of time to recreate them on a new site or edit for the existing one. Unfortunately, Magento 2 offers no tools that simplify this process. But the platform would never be so cool without its ecosystem of third-party extensions, so meet the Improved Import & Export Magento 2 extension – your number one tool for running import and export processes.

The module enables the missing ability to import and export URL rewrites to/from Magento 2. Besides, it adds dozens of other vital features the platform lacks by default, but let’s take a look at the Magento 2 URL rewrites import/export functionality first.

Sample CSV for Magento 2 Import of URL Rewrites

The url rewrites import and export files come with the following set of attributes that represent the rewrite settings. You can get the sample files for import and export with every attribute value set from:

Now, let’s describe each attribute used in the Magento 2 import of URL rewrites. You can see them along with the required values in the table below:

Attribute Name Reference Values Value Example
url_rewrite_id ID of the URL rewrite. It can be found under Marketing>URL rewrites, in the ID column. Use this if you want to update a particular rewrite. Can only contain numerals 321
entity_type Create URL Rewrite setting of the URL rewrite. Defines the type of entity for URL rewrite. Required attribute.

Available values:

category – For Category

product – For Product

cms-page – For CMS Page

custom – For Custom

category
entity_id ID of the entity of the URL rewrite. For example, if you are creating a URL rewrite for a particular product  – you need to specify the ID of this very product. Can only contain numerals 123
request_path Request Path of the URL rewrite. The path the visitor needs to hit to get redirected. Required attribute.

The paths are specified in a reference to the store name. Does not contain the full store name.

For example:

store.com/path1

Should look like

/path1

/about
target_path Target Path of the URL rewrite. The path the visitor will be redirected to when proceeded by request_path. Required attribute.

The paths are specified in a reference to the store name. Does not contain the full store name.

For example:

store.com/path1

Should look like

/path1

/about-us
redirect_type A redirect type of the URL rewrite. Defines the type of redirect for the URL rewrite for search engines. Required attribute.

0 – No type

302 – Temporary (302)

301 – Permanent (301)

302
store_id Store of the URL rewrite. Needs to be the ID of the store view where the URL rewrite is applicable. Required attribute.

Store View Code can be found under Stores > All Stores > next, click required store view and check the “Code” column.

1
description Description of the URL rewrite used for identification purposes Can be any value Test category redirect
is_autogenerated Defines if the URL rewrite has been automatically generated by Magento 2 or manually created. 0 – manually created

1 – automatically generated

0
metadata Optional attribute Apply value only if you know what you are doing {“category_id”:”47″}

NOTE that request_path and target_path contain only the path after the store URL. For example:

store.com/path1

Should look like this:

/path1

How to Import Magento 2 URL Rewrites

By installing the Improved Import & Export Magento 2 extension, you enable the following features related to the Magento 2 import of URL rewrites:

  • Import all URL redirect types:
    • No,
    • Temporary (302 redirects),
    • Permanent (301 redirects);
  • URL rewrites update with new target paths;
  • URL rewrites bulk delete.

To import Magento URL rewrites, follow these steps:

  1. Go to System -> Improved Import / Export -> Import Jobs and click the Add New Job button.
    magento 2 import url rewrites: add new job

  2. Configure General Settings and proceed to the Import Settings section. Select URL Rewrite among the options of the Entity drop-down.
    magento 2 import url rewrites: select entity
  3.  Configure other job sections: choose the import behavior, file type, data source, etc. Save the job, and run the Magento 2 import of URL rewrites.

magento 2 import url rewrites: import runYou can find more nuances associated with the import process here: Improved Import & Export Extension Manual. Also, contact us to get help with the Magento 2 URL rewrites import.

How to Export Magento 2 URL Rewrites

The export of the Magento 2 URL rewrites is pretty much the same. You need to proceed to System -> Improved Import / Export -> Export Jobs, hit the Add New Job button, and configure your export profile. That’s it. 

magento 2 url rewrite export

You can find more nuances associated with the export process here: Improved Import & Export Extension Manual. Also, contact us to get help with the Magento 2 URL rewrite export.

Get Improved Import & Export Magento 2 Extension

Other Features

The Improved Import & Export Magento 2 extension offers lots of other features related to the import/export possibilities regarding URL rewrites. First of all, it is necessary to mention that you can run all operations based on a store view or website.

Next, we’d like to draw your attention to the fact that it is possible to do all the operations right within the Magento 2 backend. You don’t need to have coding experience or advanced Magento skills to run import/export processes. Just open a corresponding section of the module (import or export), create a new profile, and specify transfer parameters. And you can fully automate every Magento 2 URL rewrite import and export!

Schedules

The Improved Import & Export Magento 2 extension offers a very flexible system of scheduled jobs that allows you to switch data transfers to autopilot. The module supports cron so that you can create any update period. Use the default cron syntax to specify a schedule that suits your particular business needs.

In addition to custom intervals, the Improved Import & Export extension offers a list of predefined values. You can select one and apply any changes to it with the help of the syntax mentioned above.

Besides, it is possible to avoid schedules and create a profile that can be launched in a manual mode only. You can run it for non-periodical updates reducing the resource consumption caused by empty import/export processes.

Note that asynchronous run is enabled for scheduled profiles as well. This feature is especially useful when the data is provided before schedule, but it is an urgent update that cannot be delayed for the planned date. The Improved Import & Export Magento 2 extension lets you run any profile whenever you need.

Below, you can see how to configure a schedule:

magento 2 import url rewrites: automation

Extended Connectivity

Another essential moment we’d like to describe here is the extended connectivity options of the Improved Import & Export Magento 2 extension. While Magento works with CSV files only and most third-party extensions that enable URL rewrites transfers don’t extend the existing boundaries, our module does a great job in this area.

File Formats

In addition to the standard CSV format, the extension supports multiple other standards reducing the necessity to convert data files. First of all, the Improved Import & Export Magento 2 module works with XML files. It is a prevalent standard used by multiple external platforms to run data transfers. Besides, our plugin works with JSON, ODS, and Excel files.

File Sources

As you can see, the selection of formats is huge so is the variety of file sources. You can select one of the multiple points of connection between your e-commerce store and an external system while transferring URL rewrites data.

The Improved Import & Export Magento 2 module offers an excellent opportunity to leverage your local server for the purpose mentioned above. At the same time, you can streamline a remote server to move data files to/from your website. Both file sources are available with the module due to the extended FTP/SFTP support.

The alternative solution is represented by popular cloud storage. The Improved Import & Export Magento 2 extension is integrated with Dropbox so that you can use your account in the cloud to move tables with URL rewrites to/from your store.

The third way to run the transfer is related to import processes only. Our plugin allows you to move URL rewrites data to Magento 2 right via a direct URL. Also, note that the Improved Import & Export Magento 2 extension extracts all compressed files automatically.

magento 2 import url rewrites: import sources

Alternative Ways of Import/Export

If file transfers don’t satisfy your business goals, our module offers several ways to import/export URL rewrites to/from Magento 2. First of all, you can transfer any data from Google Sheets. The corresponding procedure looks as follows:

magento 2 import url rewrites: google sheets

At the same time, the Improved Import & Export Magento 2 extension offers the ability to establish a two-way connection between your e-commerce store and any third-party platform via SOAP API, REST API, and GraphQL API. Note that the extension features an entirely suitable for all file formats, sources, alternative ways of import/export, and entities.

Rich Mapping Opportunities

Mapping functionality is another crucial aspect of the Improved Import & Export extension. The module offers lots of improvements in this area providing numerous features that save your time and effort and eliminate manual data editing. Let’s take a look at each function individually.

Attributes Mapping

Since different platforms implement different attribute standards, you cannot take the output from an external system and move it directly to your e-commerce store. Therefore, you always have to match external attributes to ones used in Magento 2. The traditional approach requires editing data files manually which is a dull routine. Luckily, the Improved Import & Export extension is designed to eliminate it.

The plugin lets you use a mapping interface to match external attributes to ones used in Magento 2, becoming a number-one time-saver for all data transfers. You can make any external output suitable for the Magento 2 import within just a few clicks by applying presets for the import tables. Mapping presets are pre-made mapping schemes created by our specialists. There is no need to match attributes on your own if you use them. Merely select a platform that provides the import file in the import profile section and apply the corresponding mapping preset. Let’s take a look at how to import URL rewrites from Magento 1 to Magento 2 with the help of the procedure we’ve just described:

magento 2 import url rewrites: platform presets

Go to the ‘Select a Platform’ field, choose a preset for mapping Magento 1 attributes to ones used in 2.x, and click the ‘Load Map Attributes’ button. You can also view sample files which are available below the presets drop-down.

Now, let’s tell a few more words about how everything works. As you can see, the Improved Import & Export extension maps attributes automatically. It compares the system attributes of Magento 2 with the ones specified in the import file. Next, the module maps the fields of the table that are not suitable for system requirements to the corresponding system values. As a result, you get a grid with matched attributes:

magento 2 import url rewrites: mapping

Please, contact our support regarding mapping presets for your specific business case. Leave your requests here: Firebear Help Center.

Note that you can complete the same procedure manually in the same import or export profile in the admin section of your store. Open the mapping section and add a new mapping row. Go to the ‘System Attribute’ column and select a default Magento 2 attribute there. Next, specify a corresponding import attribute in the ‘Import Attribute’ column.

magento 2 import url rewrites: mapping

Note that there is the third column where you can apply hardcoded or default values which are specified for each imported item in the corresponding column automatically. Thus, it is possible to define the same store view for all elements in the table by adding the corresponding value to the appropriate attribute in the “Default Value” column.

Also, note that all mapping schemes are saved and stored within the Improved Import & Export extension. The module automatically applies them for further updates. The mapping procedure becomes a one-time process, which is not possible in case of the default Magento tools or most third-party extensions. You either need to map everything manually or repeat mapping before every update.

Attribute Values Mapping

The Improved Import & Export Magento 2 extension allows you to map not only attributes but also their values. Thus, you no longer have to edit them manually to make them suitable for the specific e-commerce requirements or import unsuitable ones. With our module, you can quickly match external attribute values to the corresponding values used within your website. You can find the necessary tools in the mapping section described above. To achieve the goal, select an external attribute, map it to the internal one, and match their values.

The following example shows how you can use the attribute values mapping functionality introduced in the Improved Import & Export Magento 2 extension. Let’s assume that you have an update file that contains product data with the “color” attribute which has several values: “deep-blue” and “ultramarine-blue” for instance.

Now, let’s take a look at your database. There is only one value that matches the ones above – “blue.” Use the Improved Import & Export Magento 2 extension to map both external values to the one used inside your store. Thus, you will import products with the new color value: just “blue” for both instead of “deep blue” and “ultramarine blue.”

Attribute Values Editing

The previous feature has an equivalent that helps you act in a slightly different manner when it comes to attribute values. With the Improved Import & Export Magento 2 extension, it is possible to edit multiple values in bulk using various rules. Combine the following rules to implement more precise edits.

  • Adding prefixes to attributes. For instance, you have “color” as an attribute that you need to modify. It is necessary to replace the “green” value with “lime-green.” If your database includes multiple products labeled with the first value, you may spend weeks replacing the initial color with the new one. Instead, you can add the “lime-” prefix to the existing value automatically.
  • Adding suffixes to attributes. The opposite action is possible as well. If necessary, you can combine them creating a more powerful rule.
  • Split data stored in one block. The Improved Import & Export Magento 2 extension allows splitting data stored in one block into multiple blocks.
  • Merge data from various blocks. The opposite rule can also be created, so if you need to combine data from multiple blocks, it is not a problem.

The Improved Import & Export Magento 2 extension provides the ability to use RegEx to edit values stored right in the source file. For further information, read this article: How to Modify Attribute Values During Import and Export in Magento 2.

Attributes On The Fly

Another feature related to attributes is the ability to create them on the fly. With the Improved Import & Export Magento 2 module, you are always saved from issues caused by the lack of attributes in the import file. The module lets you replace the attribute name with the data necessary to create a missing attribute. Use this general format to generate attributes on the fly during import:

Use a pipe symbol to separate values and start each attribute column with ‘attribute’. The full scheme for creating attributes on the fly looks as follows:

You can find more information about attributes on the fly creation here: Product attributes import.

Category Mapping

The last mapping feature we’d like to describe in this article is category mapping. The Improved Import & Export Magento 2 extension lets you save lots of time by matching external categories to the existing ones or creating something utterly new right during the import process.

To enable the appropriate functionality, visit the Map Categories section of your import profile. Here, you can load values from the ‘categories’ column available in your import table. Clicking the ‘Load Categories From Import File’ button. Next, hit the ‘Add New’ button. In the newly displayed grid, find the ‘Import category path’ column and choose an external category from the import file. Now, you can match it to an appropriate Magento 2 category using the ‘New category path’ column:

category mapping for products

Note that you can create new categories to run products import to them right from the profile page. Click the ‘New Category’ button to proceed to the corresponding section. On a new screen, you can specify the name of your new category as well as select its parent category just like shown below:

add new category on import

The following video illustrates more features of the Improved Import & Export Magento 2 extension:

Magento 2 URL Rewrites FAQ

What is meant by URL rewriting?

URL rewriting is associated with changing a URL to the required format. Consequently, existing URLs become more search engine friendly and easier for humans to read. Usually, it works as follows: When the URL is entered into the Web server, the URL rewrite engine enters the game. It modifies the syntax behind the scenes to enable the appropriate Web page or database item to be retrieved.

What is the use of Magento 2 URL rewrite?

You can rely on the URL Rewrite instruments to perform URL manipulation tasks. For instance, it is possible to define powerful rules to transform complex URLs into simple and consistent addresses, producing user and search-engine-friendly results.

What are URL rewrites in Magento 2?

The URL Rewrite tool is one of the most awesome SEO instruments available in Magento 2 by default. It empowers you with the ability to edit any URL linking to a product, category, or CMS page. Furthermore, enabling the rewrite redirects visitors who access the old link to the new address.

How do I change the URL rewrite in Magento 2?

You can change URL rewrites in Magento 2 under Admin -> Marketing -> SEO & Search -> URL Rewrites. Press the Add URL Rewrite button and select “Custom” in the Create URL Rewrite select box. After that, you need to decide for which store view you apply the changes. Next, specify the redirection path in the Request Path field.

How do I change the target path in Magento 2?

You can change the CMS Page’s target path under Content -> Pages:
– Choose a page you want to work with and click Edit.
– Expand the Search Engine Optimization drop-down.
– Update the Magento URL Key.
– Save the changes.

How do I get a product URL?

You can get a product URL under Admin -> Marketing -> SEO & Search -> URL Rewrites. Press the Add URL Rewrites button in the upper-right corner. You will see the dropdown list of Create URL Rewrites. Select the “For Product” option here. The product list displays. Hit the product that you want to apply changes to.

How is the user-friendly URL of a product or category defined?

Since the URL key is part of a static URL that describes a product or category page, you have to make it friendly for users and search engine bots. It is recommended to add the product name and keywords to URL keys to improve the way they are indexed by search engines. Also, note that it is possible to configure a URL key to create an automatic redirect if it changes.

How to import and export Magento 2 URL rewrites via API?

With the Improved Import & Export extension, you can create an API connection between your Magento 2 website and any external platform to transfer URL rewrites.

How to import and export URL rewrites in Magento 2 automatically?

Since the Improved Import & Export extension incorporates cron, you can leverage the module to create a schedule of import and export processes. Consequently, you can create a connection and update the data regularly within the specified time frames.

How to import Magento 2 URL rewrites from Google Sheets?

If your URL rewrites are stored in Google Sheets, it is no longer an issue. The Improved Import & Export Magento 2 extension lets you transfer them directly from this platform.

Conclusion

As you can see, Magento 2 URL rewrites are a powerful addition to every e-commerce website. You can use it to make your store links more readable from the perspective of both customers and search engines. You can easily enable the corresponding functionality in your admin. However, manual editing of page addresses may be extremely time-consuming. Therefore, it is better to import the corresponding data. Automated import and export processes are a piece of cake if you use the Improved Import & Export Magento 2 extension and the Magento 2 import of  URL rewrites is not an exception. If you still have any questions regarding the functionality of our module, follow the link below and contact our support:

Get Improved Import & Export Magento 2 Extension