In Magento 2, the URL Rewrite tool empowers online merchants to create custom URLs, making them more user-friendly and search engine optimized. This feature plays a significant role in enhancing website navigation, improving SEO rankings, and providing a seamless experience for customers.
In this post, we will explore the two primary types of rewrites – Single URL Rewrite and Multiple URL Rewrite and show you how to enable URL rewrite in your Magento 2 store and demonstrate how to generate custom URLs for products, categories, and custom pages, all from the convenience of your store’s backend.
What Is URL Rewrite In Magento 2 Tool?
Magento 2 URL Rewrite is a powerful tool and feature within the Magento 2 e-commerce platform that allows you to modify/ edit any URLs in your store (e.g. URLs of the Product page, Category page, CMS page, etc.).
It provides the ability to create user-friendly and SEO URLs, improve website navigation, and handle URL redirects effectively. After changes, when anybody accesses the old URL, they will be redirected automatically to the new URL.
Here is an example of Magento 2 URL Rewrite:
- Before: https://www.example.com/laptops.html
- After URL rewrite: https://www.example.com/best-laptops
In this tutorial, we will show you how to configure URL rewrites in the back-end step-by-step.
Type of URL Rewrite
There are two main types of URL rewrites in Magento 2: Single URL Rewrite and Multiple URL Rewrite.
1. Single URL Rewrite
The Single URL Rewrite tool in Magento 2 enables you to create custom URLs for specific pages, such as products, categories, or CMS content. By customizing the URL key, you can make it more descriptive, relevant, and SEO-friendly. Key features of Single URL Rewrite include:
a. Customization: You have the flexibility to manually define the URL key for each page, allowing you to create meaningful and human-readable URLs.
b. SEO Optimization: Creating keyword-rich URLs can improve your store’s visibility in search engines and potentially increase organic traffic.
c. Redirects: When you create a URL rewrite, Magento 2 automatically manages the redirects from the old URL to the new one. This ensures a seamless user experience and avoids broken links.
d. Canonical Tags: The system generates canonical tags to prevent duplicate content issues, as different URLs might point to the same content.
For example, if you have a product with the default URL:
https://example.com/catalog/product/view/id/123, you can use the Single URL Rewrite feature to create a custom URL like
https://example.com/custom-product-url.html for better readability and SEO purposes.
2. Multiple URL Rewrite
The Multiple URL Rewrite, also known as “URL Rewrites Management,” allows you to create multiple custom URLs for the same product or page. This feature is useful when you want to offer different entry points or variations for the same content. Key features of Multiple URL Rewrite include:
a. Flexibility: You can create multiple custom URLs that point to the same page, providing various entry points for users.
b. Targeted Marketing: Multiple URL rewrites enable you to create specific URLs for marketing campaigns, allowing for better tracking and audience segmentation.
c. Regional Targeting: You can create different URLs based on regions or languages, providing localized experiences for your customers.
For instance, using the Multiple URL Rewrite feature, you can create additional custom URLs for the same product, such as:
https://example.com/special-promo-url.html(URL for a promotional campaign)
https://example.com/region-specific-url.html(URL specific to a particular region or language)
Each custom URL can serve different purposes and cater to specific audiences, helping you enhance your marketing efforts and user engagement.
How To Enable URL Rewrite In Magento 2?
URL Rewrite is typically enabled by default in Magento 2, but if you find that it’s not working or you need to confirm its status for sure, you can follow these steps to enable URL Rewrite in Magento 2:
Step 1: Go to the admin panel, navigate to Store and choose Configuration (under Settings)
(Admin Panel => STORES => Configuration)
Step 2: Select Web in the left panel, under the General section
Expand the General section, then choose Web in the dropdown.
Step 3: Expand Search Engine Optimization section
After expanding the Search Engine Optimization, you must select Yes for the only field – Use Web Server Rewrites.
Step 4: Save the config
After setting “Use Web Server Rewrites” to “Yes,” click on the “Save Config” button at the top right corner to save the changes.
How To Generate URLs Rewrite in Backend
Step 1: Go to the admin panel, navigate to Marketing and choose URL Rewrites
(Admin Panel => Marketing => URL Rewrites)
Step 2: Click the Add URL Rewrite button to create a new rewrite
Step 3: Choose the Type of Rewrite
- For Product URL: Select Product from the Create URL Rewrite dropdown.
- For Category URL: Select Category from the Create URL Rewrite dropdown.
- For Custom Page URL: Select Custom from the Create URL Rewrite dropdown.
Step 4: Select the Store View
- Choose the specific Store View for which you want to create the URL rewrite.
- To apply the rewrite to all store views, leave the Store View field as All Store Views.
Step 5: Enter the Old and New URLs
- In the Request Path field, enter the old URL that you want to redirect from (e.g., old-category-page.html).
- In the Target Path field, enter the new URL that you want to redirect to (e.g., new-category-page.html).
Step 6: Choose the Redirect Type and Save the URL rewrite
- Permanent (301): Use this for permanent changes with SEO value transfer to the new URL.
- Temporary (302): Use this for temporary changes, keeping SEO value with the old URL.
Click on the Save button to create the URL rewrite.
We’ve explored the ease of enabling URL rewriting in your Magento 2 store and the step-by-step process of generating custom URLs for products, categories, and custom pages. Now armed with this knowledge, you can effortlessly create meaningful URLs that resonate with your customers and positively impact your store’s online presence.
We hope this guide has been a valuable resource for you in understanding how to generate URL rewrite in Magento 2. Now, it’s time to put this knowledge into action and transform your e-commerce store into a user-friendly and SEO-optimized shopping destination.
See More Our Magento “How To” Series: