How to Manage Magento 2 URL Rewrite Table?

How to Manage Magento 2 URL Rewrite Table?

Want to simplify URL management in your Magento 2 store? Magento 2 URL rewrite table is your go-to tool for creating clean, SEO-friendly URLs.

In this tutorial, we will explore the key components and managing steps of the Magento 2 URL rewrite table.

Best Magento Hosting now

Key Takeaways

  • URL rewrites improve SEO and user navigation.

  • Get step-by-step guidance on managing URL rewrites.

  • Optimize URLs for better search rankings and user experience.

  • Save time with automated and programmatic URL rewrite tools.

  • Ensure a secure and organized URL structure for your store.

What is the Magento 2 URL Rewrite Table?

What is the Magento 2 URL Rewrite Table

The Magento 2 URL rewrite table is a database feature that manages URL redirection and rewriting for better SEO and navigation.

The feature stores rules to map non-user-friendly or outdated URLs to clean, keyword-rich paths. The table helps create consistent, SEO-friendly URLs for products and CMS pages.

URL rewrite also handles 301 and 302 redirects. It ensures users reach the correct pages even if the original links change. Magento automatically updates this table when URLs are modified.

The table improves search engine rankings and prevents broken links by managing URL rewrites effectively.

Key Components of the Magento 2 URL Rewrite Table

1. Request Path

  • It is the URL entered by the user or a search engine. It represents the old, non-user-friendly, or outdated URL that needs to be rewritten or redirected.

  • For example, catalog/product/view/id/10 might be mapped to a cleaner, SEO-friendly version like men/shoes.

2. Target Path

  • It is the destination URL where users are redirected. It ensures they land on the correct page.

  • For instance, a deprecated link like old-product-url can point to a new link, such as new-product-url.

3. Redirect Type

  • Magento supports two primary types of redirects

  • 301 redirect informs search engines and browsers that the original URL has been permanently moved to the target path. It helps retain SEO rankings for the new URL.

  • 302 redirect is used for temporary changes. It directs traffic to a different URL without permanently altering the original link.

4. Entity Type

  • The field identifies the type of Magento entity with which the URL rewrite is associated.

  • Common entity types include:

    1. Product: URLs for specific products.

    2. Category: URLs for categories within the store.

    3. CMS Page: URLs for static content pages like "About Us" or "Contact."

5. Entity ID

  • Every product, category, or CMS page in Magento has a unique identifier (ID).

  • The ID helps the system map the rewrite to the exact entity in the database. It ensures precision in redirection.

6. Store ID

  • Magento supports multiple store views. It allows you to cater to different languages or regions.

  • The Store ID ensures that URL rewrites apply to the correct store view. It helps avoid conflicts between URLs in different views.

7. Is Autogenerated

  • The field indicates whether the URL rewrite was created automatically by Magento or manually by an admin.

  • It is autogenerated when products, categories, or pages are added or updated.

  • Store admins manually create it to address specific needs. These include custom redirects or special URL paths.

8. Metadata

  • While not always visible, additional data like options or parameters can sometimes be included for advanced customizations. This is especially true in programmatic setups.

How to Manage URL Rewrite Table in Magento 2?

1. Enable web server rewrites via the Admin Panel

Enable web server rewrites via the Admin Panel

  • Log in to the Admin Panel.

  • Navigate to Stores > Configuration > General > Web.

  • Under the drop-down menu of the Search Engine Optimization section, set Use Web Server Rewrites to Yes.

  • Save the changes by clicking Save Config.

2. Configure automatic URL redirects

Configure automatic URL redirects

  • Go to Stores > Configuration > Catalog > Catalog.

  • In the drop-down menu of the Search Engine Optimization section, set Create Permanent Redirect for URLs if the URL Key is changed to Yes.

  • Click Save Config to apply the changes.

3. Change product or category page URLs

Change product or category page URLs

  • Navigate to Products > Catalog and select the product or category to update.

  • In the drop-down menu of the Search Engine Optimization section, update the URL Key using only lowercase characters.

  • Save the changes and refresh the cache.

4. View the URL rewrite table

View the URL rewrite table

  • Go to Marketing > SEO & Search > URL Rewrites in the Admin Panel.

  • The table will display all URL redirects, with the most recent entries at the top.

5. Add a New URL Rewrite

Add a New URL Rewrite

  • Navigate to Marketing > SEO & Search > URL Rewrites.

  • Click the Add URL Rewrite button and configure the following:

    1. Create URL Rewrite: Choose the custom option for a product, category, or CMS page.

    2. Store: Select the store view.

    3. Request Path: Enter the new URL key and suffix.

    4. Target Path: Specify the destination path.

    5. Redirect Type: Choose Temporary (302) or Permanent (301) redirect type.

    6. Description: Provide details about the rewrite.

  • Save your changes.

Best Practices for URL Rewrites

1. Use Simple and Descriptive URLs

Use Simple and Descriptive URLs

  • A clear, concise, and meaningful URL helps both users and search engines understand the content.

  • You should include keywords that describe the page content. It helps improve SEO and user click-through rates.

Do:

example.com/red-winter-coat – Clearly describes the product.

Avoid:

example.com/product?id=1234 – Confusing and provides no context.

2. Maintain Consistency in URL Structure

  • A logical and consistent URL structure creates an organized navigation experience. It also makes your website easier to crawl for search engines.

  • Hierarchical URLs also give users context about their location within the site.

Do:

  • example.com/blog/2024/seo-tips for a blog post in a category.

  • example.com/shop/mens/shoes for a product in a subcategory.

Avoid:

  • example.com/seo-tips (without categorization).

  • example.com/shoes (without proper subcategorization).

3. Prevent Duplicate Content Issues

  • Duplicate content can confuse search engines and dilute ranking potential.

  • Assign a unique URL to each page. You should also use canonical tags when similar content is available across different URLs.

Example:

  • Canonicalize example.com/shirts for multiple versions like example.com/shirts?color=red or example.com/shirts?size=large.

4. Keep URLs Short and Focused

Keep URLs Short and Focused

  • Shorter URLs are easier to share and remember.

  • They should focus on essential keywords and exclude redundant information.

Do:

  • example.com/mens-t-shirts.

Avoid:

  • example.com/shop/men/winter/fashion/t-shirts-available-now.

5. Use Hyphens Instead of Underscores

  • Hyphens improve readability for both users and search engines.

  • They are the preferred word separator in URLs. You should avoid underscores or spaces that can complicate crawling.

Do:

  • example.com/mens-shoes.

Avoid:

  • example.com/mens_shoes or example.com/mens%20shoes.

6. Implement Proper Redirects

  • When changing URLs, you should ensure old URLs redirect users to the new ones.

  • Always use 301 redirects for permanent URL changes. It helps preserve SEO value and provide a smooth user experience. Avoid 302 redirects and minimize redirect chains for permanent changes.

For example:

  • Avoid: Old URL → Intermediate URL → Final URL.

  • Aim: Old URL → Final URL.

7. Secure URLs with HTTPS

  • Switching from HTTP to HTTPS secures user data and is a ranking factor in SEO.

  • After URL rewrites, ensure all rewritten URLs point to their HTTPS versions. Update internal links to reflect this change.

8. Test URLs After Rewriting

  • After implementing rewrites, test to ensure they work as intended.

  • Broken links or improperly configured redirects can lead to errors. It harms user experience and SEO.

How to Test:

  • Use tools like Screaming Frog or Google Search Console to identify 404 errors.

  • Check redirects to verify proper functionality.

9. Optimize URLs for SEO

  • Make sure each rewritten URL contains the page's primary keyword.

  • Avoid keyword stuffing or irrelevant terms that may confuse users and reduce SEO effectiveness.

Do:

  • example.com/seo-best-practices.

Avoid:

  • example.com/article?id=1023&topic=seo.

10. Document All URL Changes

  • Keep a record of URL rewrites, including the old and new URLs, for troubleshooting and consistency.

  • Share the document with your team to maintain alignment.

Why It’s Important:

  • Helps with tracking redirects.

  • It prevents duplication of effort in the case of future rewrites.

Tools for Managing URL Rewrites in Magento 2

Tools Purpose How Features Ideal For Limitations
1. Magento 2 Admin Panel The admin panel provides a user-friendly interface for creating and managing URL rewrites. Go to Marketing > SEO & Search > URL Rewrites in the Magento Admin. Add custom URL rewrites for products or CMS pages. Edit or delete existing URL rewrites. Search and filter existing URL rewrites by request path or store view. Simple and manual tasks like fixing specific broken links or setting up custom redirects. It is time-consuming for bulk changes. It offers limited flexibility compared to programmatic or automated methods.
2. Magento CLI (Command Line Interface) The Magento CLI allows developers to perform bulk URL rewrite operations efficiently. Developers can use CLI commands to regenerate URL rewrites for products or categories when changes are made. It helps save time when handling a large number of URLs. It can be automated as part of broader maintenance scripts. Developers managing large catalogs or frequently updated stores. Technical knowledge is required for it to be used effectively.
3. Extensions and Modules Third-party extensions enhance Magento’s built-in capabilities for managing URL rewrites. Amasty URL rewrites provide bulk management and advanced filtering. Mageplaza SEO toolkit combines URL rewrite management with other SEO features. Bulk URL rewrites for products and CMS pages. Automatic generation of redirects for changed URLs. Broken link detection and management. Store admins who are looking for an easier, feature-rich interface. It doesn’t require any technical coding. It may require additional costs. Compatibility issues can arise with certain custom setups.
4. Database Management Tools It helps directly manage URL rewrites in the url_rewrite database table. It is for advanced customization or debugging. These tools include phpMyAdmin, a web-based database management tool, and MySQL Workbench for advanced SQL tasks. There are issues with debugging when URL rewrites are not working as expected. Bulk updating or deleting records using SQL queries. Technical users who are familiar with SQL and database structures. Risk of errors if queries are incorrect. Changes may bypass Magento’s indexing system, requiring a manual reindex.
5. Magento API It allows developers to manage URL programmatically rewrites through Magento’s REST or GraphQL APIs. Use API endpoints to create, update, or delete URL rewrites. Integrate with external systems or automation tools for streamlined operations. It enables automated workflows. It is useful for custom integrations or headless Magento setups. Advanced developers and businesses using third-party systems that require dynamic URL management. It requires API knowledge and setup. It is not suitable for one-off manual changes.
6. SEO Auditing Tools External tools to monitor and optimize URL rewrites from an SEO perspective. Screaming Frog scans your site for broken links and duplicate content. SEMrush and Ahrefs identify SEO issues related to URLs, such as non-canonical URLs or broken pages. Highlight problematic URLs that need to be fixed or redirected. Provide insights into how URL structure affects SEO performance. Businesses focusing on SEO and are looking to maintain URL health. They cannot directly manage URL rewrites in Magento. They are used for analysis only.

FAQs

1. How does the Magento URL rewrite tool work for products and categories?

The Magento URL rewrite tool lets you change any URL for products and categories. It updates the current URL in the system. It ensures previous URLs are redirected to the new ones seamlessly. These changes are stored in rewrite tables by default.

2. What is the role of the URL rewrite module for product URLs?

The URL rewrite module updates the canonical product URL. It removes unnecessary parameters specified in the URL. It also allows you to create custom rewrites for any product or category URL. It improves the store’s SEO and user navigation.

3. How can I create a permanent redirect for old URLs in Magento 2?

Select the redirect for the old URL checkbox when changing a URL key. It ensures that previous URLs are redirected to the new ones using a permanent redirect for the old URL. These rules are saved in the url_rewrite table for consistent performance.

4. Why does Magento Commerce use URL rewrites for SEO?

Magento Commerce uses URL rewrites to remove unnecessary words or file extensions that normally appear in the URL. It simplifies URLs, adds high-value keywords, and sets one URL as the canonical version. These features enhance the SEO and performance of your store.

CTA

Summary

The Magento 2 URL rewrite table manages URL redirection and rewriting for better SEO and navigation. The tutorial explores the components of the rewrite table, including:

  • Request path maps old URLs to user-friendly ones.

  • The target path defines the destination URL for redirection.

  • Entity details track product, category, or CMS page associations.

  • Redirect types support 301 (permanent) and 302 (temporary) redirects.

Enhance your store's SEO and user experience with smooth URL management. Explore managed Magento hosting for optimized performance and expert support.

Ruby Agarwal
Ruby Agarwal
Technical Writer

Ruby is an experienced technical writer sharing well-researched Magento hosting insights. She likes to combine unique technical and marketing knowledge in her content.


Get the fastest Magento Hosting! Get Started