The Most Popular Extension Builder for Magento 2

With a big catalog of 224+ extensions for your online store

Magento 2 SEO Friendly URL - Configure Friendly URL

SEO Friendly URL indicates links that are short but full of keywords. It can help your store site rank higher in search engines, which drives more traffic and builds higher trust. Besides that, visitors find it easier to remember and navigate with a short and concise URL. Hence, it is one of the first steps to make your store SEO optimized.

Configure URL Rewrite Magento 2 is one of the most awesome tools by Magento 2 that allows you to edit any URL links to a product, category or CMS page. After enabling the URL rewrite, the visitors who access the previous link will be navigated to the new address to get more information.

URL without Web Server Rewrite

http://www.yourdomain.com/magento/index.php/storeview/url-identifier

URL with Web Server Rewrite

http://www.yourdomain.com/magento/storeview/url-identifier

From the Magento 2 backend, it is possible to configure the URL Rewrite to make the current URL more friendly with every search engine as well as easier for the readers. To do that, the Web Sever Apache Rewrites needs to be enabled, and then the system rewrite will auto-ignore the file name “index.php”, simultaneously, the words that convey nothing of value to search engines or customers, and has no effect on the performance or site rank.

Table of Contents

What Are URL Rewrites?

URL Rewrite is a popular technique that is widely used no matter what platform they are built on. In simpler terms, URL Rewrite allows you to rewrite the original URLs generated by the systems, which are often complicated and harmful to your rankings and the customer experience.

As a result, URL keys can be modified to be shorter, more transparent, and more meaningful than the old keys.

Advantages of Magento 2 URL Rewrites

Have you ever wondered if a friendly URL is really vital for your Magento 2 store? The answer is Yes, of course. The URL is the first thing Google and visitors will see when they visit your website. URLs that are friendly, easy-to-read, and contain keywords describing the content of your website will help users remember your website address easily, and of course, it helps your website rank higher on the SERP. Therefore, URL Rewrite is an extremely necessary thing for SEO activities on the website. Here are some advantages of Magento 2 URL Rewrites:

  • Simplicity: When you rewrite URLs, it enables you to show shorter URLs because long and complicated URLs will distract the user instead of engaging it. As a result, visitors may misunderstand your website.
  • Boost SEO: Magento 2 URL Rewrites allow store owners to technically change the hierarchy of their website, which helps you drive SEO better.
  • Keywords are one of the most crucial factors that affect your website’s ranking on Google. Thus, URL Rewrites help SEO professionals manage URL keywords regardless of technical contemplations. What’s more, these techniques make it easier for search engines to understand your website.
  • Improve website visibility: Typically, URLs in the top 10 of search results are 36 characters long on average. That’s why you should rewrite URLs and shorten them to increase rankings and website visibility effectively.

That’s all you need to know about URL Rewrites and the benefits they bring to your website. Now it’s time to return to our primary topic, How to Configure URL Rewrite in Magento 2. Let’s dive in!

How to Configure Magento 2 URL Rewrites?

Please follow our tutorial until the end to easily configure URL rewrites in your Magento 2 store.

Step 1: Enable URL Rewrite in Magento 2

First, you need to enable URL Rewrites in Magento 2. Some steps below will help you.

  • Log in to the Admin Panel, choose Stores > Settings > Configurations.
  • Under General, choose Web in the left panel.
  • Expand the Search Engine Optimization section.
  • Set the Use Web Server Rewrites to ‘Yes’.
  • Click the Save Config button to complete.

Enable URL Rewrite in Magento 2

Step 2: Automatically Enable URL Redirects

After enabling the URL Rewrites, it’s time to enable the Magento 2 URL redirects. This step’s primary purpose is to redirect all the old URLs to the latest URL permanently.

  • Go to Stores > Configuration > Catalog
  • Next, in the Catalog drop-down, click on Catalog
  • Open the Search Engine Optimization section
  • Choose Yes for Create Permanent Redirect for URLs if URL Key Changed.
  • Choose Save Config button to complete.
  • You can easily update/regenerate the product and category URL key, and all old URLs will be redirected to the new URLs.

Automatically Enable URL Redirects

Step 3: Enable Magento 2 Product URL Rewrite

Next, you need to create URL Rewrite for products; the following steps will help you practice.

  • From the admin panel, please navigate to Catalog > Products.
  • Choose the product(s) that you want to change the URL of.
  • Open the Search Engine Optimization section.
  • Now, you can update the URL Key to the new one. Please keep in mind that only lowercase letters & characters are allowed.
  • Last, click Save button and refresh your cache.

In case product URL Rewrites are not working, please ensure that you have cleared the cache. After doing this, all the old URLs will be redirected to the updated URLs.

Enable Magento 2 Product URL Rewrite

How to get the SEO URL of a Magento 2 product?

To retrieve the SEO URL of a product in Magento 2, you can utilize the following code snippet:

$product = $block->getProduct(); 
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$url = $objectManager->get('Magento\Catalog\Model\Product\Url')->getUrl($product);

In this code, the product object is obtained first, and then the getUrl() method of the Magento\Catalog\Model\Product\Url class is employed to obtain the SEO URL for the product. It’s possible to tailor this code to meet specific requirements, such as acquiring the URL for a particular product using its ID or employing dependency injection instead of the ObjectManager.

Magento 2 URL Rewrite Management

Admin can manage all generated URL Rewrites with ease from the admin panel. Magento will record all URL Rewrites in a single grid.

How to Check Magento 2 URL Rewrite Record

In case you want to check what custom URL Rewrites have you made, you can follow these steps below:

  • Log in to the admin panel
  • Navigate to Marketing > URL Rewrites under SEO & Search section

All regenerated URL Rewrites will be shown in a table with the most recent on the top.

All regenerated URL Rewrites

Suppose you see that all changes have not been applied; you can reindex from CLI or the admin panel.

Magento SEO Services
by Mageplaza

Let experienced professionals optimize your website's ranking

Learn more
Magento SEO service

The bottom line

If you want to increase search engine rankings for your Magento 2 store, start with configuring SEO Friendly URLs. You can follow the above guide to finish setting up, or simply use Mageplaza Better SEO solution. Feel free to leave comments and share your thoughts!

Related Post

Image Description
Hello, I'm the Chief Technology Officer of Mageplaza, and I am thrilled to share my story with you. My deep love and passion for technology have fueled my journey as a professional coder and an ultra-marathon runner. Over the past decade, I have accumulated extensive experience and honed my expertise in PHP development.

Looking for
Customization & Development Services?

8+ years of experiences in e-commerce & Magento has prepared us for any challenges, so that we can lead you to your success.

Get free consultant
development service
x

    Explore Our Products:

    People also searched for

    Subscribe

    Stay in the know

    Get special offers on the latest news from Mageplaza.

    Earn $10 in reward now!

    Earn $10 in reward now!

    comment
    iphone
    go up