How to Manage Magento 2 URL Rewrite

A Magento 2 store may undergo changes from time to time. There may be changes in product or catalog pages or changed the location entirely! In such cases, if the URL rewriting is not taken care of, then the store might lose potential customers due to landing on the page that does not exist anymore. Also, the admin would want to rewrite the URL with higher value keywords to make it more search friendly and improve the SEO of the store. If you’re going to do the same for your store, learn how to manage the Magento 2 URL rewrite!

Enable Magento 2 URL rewrite for your store when you want to redirect the old links to a new address. There are two ways to enable URL rewrites in Magento 2

  1. Via Admin Panel
  2. Programmatically

Herre, I have explained both the methods stepwise.

    1. Follow the below steps
      1. Log in to the Admin Panel
      2. Go to Stores > Configuration > General > Web
      3. Select the drop-down menu of the Search Engine Optimization section
      4. Set the Use Web Server Rewrites to ‘Yes’.
      5. Save your settings from the “Save Config” button.How to Manage Magento 2 URL Rewrite 1
    2. Configure automatic URL Redirect
      1. Go to Stores > Configuration > Catalog > Catalog
      2. Select the drop-down menu of the Search Engine Optimization section
      3. Set Create Permanent Redirect for URLs if URL Key Changed to ‘Yes’
      4. Save your settings from the “Save Config” button.How to Manage Magento 2 URL Rewrite 2
    3. Change product or category page URLs
      1. Go to Products > Catalog, select the products of which the URLs has to be rewritten
      2. Select the drop-down menu of the Search Engine Optimization section
      3. Update the URL Key here, and use only lowercase characters
      4. Save the changes and refresh the cache.How to Manage Magento 2 URL Rewrite 3

      Configuring these settings will give you the desired results. The visitors will be redirected to the new page from the old URL.

    4. See Magento 2 URL Rewrite tableNavigate to Marketing > SEO&Search > URL Rewrites in Admin Panel to see the redirect records. As shown in the image below, the most recent redirects will appear at the top of the Magento 2 URL Rewrites table.How to Manage Magento 2 URL Rewrite 4
    5. Add URL Rewrite using the Add URL Rewrite buttonGo to Marketing > SEO&Search > URL Rewrites. If you have followed the instructions above, then you are in the required tab. Click the “Add URL Rewrite” button. Configure the following settings:
      • Create URL Rewrite: Choose the custom option for category, product or CMS page.
      • Store: Select the store view
      • Request Path: Input a new URL key and suffix for the category or the product
      • Target Path: Enter the targetted path
      • Redirect Type: Choose either Temporary (302) or Permanent (301) redirect type
      • Description: Describe the rewrite
      • Save your settingsHow to Manage Magento 2 URL Rewrite 5

      Fulfill reindex via the backend or use the command: php bin/magento indexer:reindex in the case where the changes do not reflect in the result.

  1. Enable 301 URL redirect to create search redirection to go on working with the customers after building new URLs.

    Follow the below steps:

    1. Generate a constructor file
    2. Fill in custom URL rewrite in execute method
       

That’s it.
Now besides the importance of URL rewrite you know how to create and manage it

Any doubts regarding URL rewrite will be entertained in the comment section.
Don’t forget to flash 5 stars if you like my blog.

5
(based on 14 Reviews)
How to Manage Magento 2 URL RewriteAuthor Magento Badge

Sanjay Jethva

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

6 Comments

Leave a Reply

Your email address will not be published.