How do I manage URL rewrites in Magento?

Managing URL rewrites in Magento allows you to create custom URLs for your products, categories, and CMS pages, which can help improve SEO and provide a better user experience. Here's a step-by-step guide to help you manage URL rewrites in Magento:

Step-by-Step Guide to Manage URL Rewrites in Magento

Step 1: Access URL Rewrites Management

  1. Log in to the Admin Panel:

    • Go to your Magento admin URL and log in.
  2. Navigate to URL Rewrites:

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

Step 2: Create a New URL Rewrite

  1. Click on Add URL Rewrite:

    • Click the Add URL Rewrite button.
  2. Choose a URL Rewrite Type:

    • Select the Create URL Rewrite option to create a custom URL.
  3. Fill in URL Rewrite Information:

    • Request Path: Enter the URL path you want to rewrite (e.g., old-url-path).
    • Target Path: Enter the actual URL path that the request should be redirected to (e.g., catalog/product/view/id/1).
    • Redirect Type: Choose the type of redirect (usually Permanent (301)).
    • Store: Select the store view to which this URL rewrite applies.
  4. Save URL Rewrite:

    • Click Save to create the URL rewrite.

Step 3: Edit an Existing URL Rewrite

  1. Search for the URL Rewrite:

    • Use the search filters to find the existing URL rewrite you want to edit.
  2. Select the URL Rewrite:

    • Click on the URL rewrite you want to edit.
  3. Edit URL Rewrite Information:

    • Modify the Request Path, Target Path, Redirect Type, and Store as needed.
  4. Save URL Rewrite:

    • Click Save to apply the changes.

Step 4: Delete a URL Rewrite

  1. Search for the URL Rewrite:

    • Use the search filters to find the URL rewrite you want to delete.
  2. Select the URL Rewrite:

    • Click on the URL rewrite you want to delete.
  3. Delete the URL Rewrite:

    • Click the Delete button to remove the URL rewrite.

Step 5: URL Rewrites for Products, Categories, and CMS Pages

  1. Product URL Rewrites:

    • Navigate to Catalog > Products.
    • Select a product and go to the Search Engine Optimization section.
    • Modify the URL Key to create a custom URL for the product.
    • Click Save to apply the changes.
  2. Category URL Rewrites:

    • Navigate to Catalog > Categories.
    • Select a category and go to the Search Engine Optimization section.
    • Modify the URL Key to create a custom URL for the category.
    • Click Save to apply the changes.
  3. CMS Page URL Rewrites:

    • Navigate to Content > Elements > Pages.
    • Select a CMS page and go to the Search Engine Optimization section.
    • Modify the URL Key to create a custom URL for the CMS page.
    • Click Save to apply the changes.

Step 6: Manage URL Rewrites via Database

For advanced users, URL rewrites can also be managed directly via the database. However, this requires careful handling to avoid breaking links.

  1. Backup Your Database:

    • Always create a backup of your database before making direct changes.
  2. Access URL Rewrite Table:

    • Use a database management tool like phpMyAdmin or a MySQL client to access your Magento database.
    • Find the url_rewrite table.
  3. Modify URL Rewrites:

    • Insert, update, or delete rows in the url_rewrite table as needed.
  4. Clear Cache:

    • Go to System > Cache Management.
    • Select all caches and refresh.

Additional Tips

  • SEO Considerations:

    • Use descriptive and keyword-rich URL keys to improve SEO.
    • Avoid changing URLs frequently to maintain search engine rankings.
  • Redirect Management:

    • Use 301 redirects for permanent changes to preserve SEO value.
    • Use 302 redirects for temporary changes.
  • Test Changes:

    • After creating or modifying URL rewrites, test the URLs to ensure they redirect correctly.

Conclusion

By following these steps, you can effectively manage URL rewrites in Magento, enhancing your store's SEO and user experience. Proper URL management helps maintain clean, descriptive URLs that are easy for both search engines and users to understand.