Sept 9, 2020 Update: Adding an additional common URL rewrite problem which you may encounter after data migration and how to fix it.
You might be familiar with the option to add URL Rewrites in both Magento 1 and Magento 2, which is also referred to Search Engine Friendly URLs. Sometimes URL Rewrite issues arise when migrating data from Magento 1 to Magento 2. This guide will help you in troubleshooting when you encounter such issues.
What is URL Rewrite?
URL rewrites make it possible to make your existing Magento store URLs more ‘search engine friendly” and also easier for visitors to read.
Within Magento, the system URL looks similar:
- For a Product URL: /catalog/product/view/id/10
- For a Category URL: /catalog/category/view/id/11
The ‘catalog’ segment refers to the Catalog module of the Magento core, followed by other segments indicate that a product with ID 10 or a category ID 11 should be displayed on the page. No matter how often the URL changes, these ID remains the same.
When the URL Rewrites are enabled, the system removes elements that convey nothing of value to search engines or customers, for instance the file name ‘index.php’ or system segments ‘catalog/product/view/id/10’. The URL Rewrites turn these URLs into readable and SEO-friendly URLs instead:
- URL without URL Rewrite:
- URL with URL Rewrite:
In short, a URL rewrite changes the way a URL appears in the browser. The URL Rewrite tool in Magento 2 lets you change any URL that is associated with a product, category, or CMS page.
A URL redirect is often used interchangeably with the term URL rewrite, however it refers to slightly different processes. A URL redirect updates the URL that is stored on the server, which can be either temporary or permanent.
URL Rewrite Issues after migrating data to Magento 2
There are a number of URL issues after data migration. Here are two examples of URL Rewrite issues that our members have faced when using UB Data Migration Pro extension to migrate data from Magento 1 to Magento 2.
We have noticed an issue with our category and product urls after the delta migration. A few URLs turn out like this: https://www.sample.com/catalog/product/view/id/95253/s/chief-combo-boots/category/531/
In Magento 1, there was a URL rewrite index, but in Magento 2, this index is replaced by a new system to generate the URLs.
So, in most cases, you can make use of Magento 2 URL Rewrite tool to autogenerate the URLs rewrites for categories and associated products. Let’s try the below steps one by one:
- Step 1: Create a new temporary root category (eg. named ‘Temp Root Category’)
- Step 2: On the Admin sidebar, tab Stores | (Settings) All Stores, edit the default Store of the default website and set Root Category to the newly added root category ‘Temp Root Category’. Then click Save Store button.
- Step 3: Navigate to the Stores | (Settings) All Stores once again, open the default Store of the default website and switch Root Category back to your main root category which you want to publish in the storefront. Then click Save Store button. When complete, Magento 2 will automatically re-generate categories and associated products URLs rewrite for you.
NOTE: Depending on number of the categories and associated products, autogenerating may take some time.
- Step 4: Re-index the data and refresh the Magento cache.
You already tried with the solution suggested in Case 1 above (Making use of Magento 2 URL Rewrite tool to auto-generate the URLs rewrites for categories and associated products) and still encountered an issue like this:
- wrong URL for product ID 208 (French view)
- Wrong category URL and then product URL (English view)
- Missing URL rewrites
Below is a workaround for a specific Category, you can apply the same solution to other categories in any store view that you might get the issue.
- Step 1: Click to edit the category (e.g. Category ID = 5 (Bridal Jewellery)) and select the ‘English’ scope. Then, add a temporary string (-tmp) to the value of the Url Key field (e.g. bridal-jewellery-tmp). Once done, click Save button.
- Step 2: Edit the same category again and select the ‘English’ scope. Then, remove the temporary string (-tmp) in the value of the Url Key field to the original value (bridal-jewellery) and click Save button.
Once done, the wrong URL and missing URL rewrites should be resolved (e.g. https://yourdomain.com/bridal-jewellery)
NOTE: you apply the workaround above to the parent category level only. It will automatically apply to all children (sub-categories) and associated products.
We have noticed an issue with our product page urls after the migration. They end with .html.html instead of .html. This seems to be a common issue which the migration tool, what is the way you recommend to fix this.
The issue refers to some of your Magento 1 data which is not compatible with the new Magento 2’s working rules. Use the steps below to resolve them:
- Step 1: Run the following SQL queries in an SQL prompt such as phpMyAdmin (NOTE: You should check the request_path attributes in your database that have the issue. Then replace the sample attribute_ids below with your own attribute_ids):
- Step 2: Navigate to your Magento 2 backend, open and re-save each of your migrated category. Magento 2 will re-generate related category and product urls then.
NOTE: It’s important to note that the workaround above is intended for the old UB Data Migration Pro versions only. The Pro ver3.x and later automatically resolve the duplicated .html .html suffix issue for you.
In this article, we introduce the most common URL Rewrite issues that you might encounter when using UB Data Migration extension. When dealing with a more complex circumstance, you may need to submit a ticket on our helpdesk here, we will help you in troubleshooting on case by case basis.