Magento 2 Search Engine Friendly URL – Configure URL Rewrite
An SEO-friendly URL consists of short, keyword-rich links that can significantly improve your store's ranking in search engines. Such URLs not only drive more traffic but also enhance the credibility of your site. Additionally, concise URLs are easier for visitors to remember and navigate, making them a crucial element of SEO optimization.
Configuring URL rewrites in Magento 2 is an incredibly useful feature that allows you to modify any URL links associated with products, categories, or CMS pages. By enabling URL rewrites, visitors who try to access the old links will be automatically redirected to the new addresses, ensuring they can still find the information they need.
Implementing SEO-friendly URLs and configuring URL rewrites in Magento 2 is a proactive strategy for improving both user experience and search engine visibility. As you optimize your store, these practices can lead to better engagement and higher conversion rates.
Moreover, having well-structured URLs is essential for search engines to crawl and index your site effectively. By using clear and descriptive URLs, you help search engines understand the content of your pages, which can further enhance your site's performance in search results.
Overall, focusing on SEO-friendly URLs and efficient URL rewrite configurations in Magento 2 is a foundational step towards creating a successful and optimized online store.
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
In Magento 2, you can easily configure URL rewrites from the backend to enhance the friendliness of URLs for both search engines and users. This process helps in creating cleaner, more descriptive URLs that improve the overall user experience and SEO performance of your store.
To start, it is essential to ensure that Apache's Web Server Rewrites are enabled. This setting allows the system to automatically ignore the file name "index.php" resulting in more straightforward and aesthetically pleasing URLs. This simplification is crucial for improving the readability and shareability of your links.
Additionally, URL rewrites help eliminate unnecessary words that do not add value for search engines or customers. By streamlining your URLs, you can focus on conveying meaningful information while also enhancing site performance and rankings in search results.
By following these steps and utilizing the URL rewrite feature, you can create a more SEO-friendly environment for your Magento 2 store, ultimately leading to increased traffic and improved user engagement.
Overall, configuring URL rewrites is a vital aspect of optimizing your online presence, making it easier for potential customers to find and navigate your store effectively.
What Are URL Rewrites?
URL Rewrite is a widely adopted technique across various platforms that enhances the usability and SEO performance of websites. Essentially, URL Rewrite enables the modification of original URLs generated by systems, which are often long and complex, potentially harming both search rankings and the overall customer experience.
By implementing URL rewriting, you can transform cumbersome URLs into shorter, clearer, and more descriptive links. This improvement not only makes it easier for users to understand the content of the page but also helps search engines index your site more effectively, leading to better visibility and higher traffic.
Advantages of Magento 2 URL Rewrites
Have you ever considered the importance of a friendly URL for your Magento 2 store? The answer is a resounding yes. The URL is the first element that both Google and visitors encounter when accessing your website. Friendly URLs that are easy to read and contain relevant keywords help users remember your website address and significantly improve your website's ranking on search engine results pages (SERPs). Therefore, implementing URL Rewrite is essential for optimizing your site's SEO.
Here are some advantages of using URL Rewrites in Magento 2:
- Simplicity: By rewriting URLs, you can create shorter, more concise links. Long and complicated URLs can confuse users, whereas simple URLs are more engaging and user-friendly.
- Boost SEO: URL Rewrites allow store owners to adjust the website hierarchy, which enhances SEO performance and improves search engine rankings.
- Keyword Management: Keywords are crucial for Google rankings. URL Rewrites enable SEO professionals to manage and optimize URL keywords effectively, making it easier for search engines to comprehend your website content.
- Improve Website Visibility: Typically, URLs in the top search results average around 36 characters in length. By shortening and rewriting your URLs, you can enhance your website's visibility and ranking in search results.
That’s all you need to know about URL Rewrites and their benefits. Now, let’s 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.
To configure URL rewrites in Magento 2, start by logging into the Admin Panel. Then, navigate to Stores > Settings > Configurations.
Next, follow these steps:
- Under the General section, select Web from the left panel.
- Expand the Search Engine Optimization section.
- Set the Use Web Server Rewrites option to ‘Yes’.
- Click the Save Config button to apply the changes.
Step 2: Automatically Enable URL Redirects
Once you have enabled the URL Rewrites, the next step is to activate the Magento 2 URL redirects. This process ensures that all old URLs are permanently redirected to their latest counterparts.
To enable URL redirects, follow these steps:
- Navigate to Stores > Configuration > Catalog.
- In the Catalog drop-down menu, click on Catalog.
- Open the Search Engine Optimization section.
- Set Create Permanent Redirect for URLs if URL Key Changed to Yes.
- Click the Save Config button to finalize your changes.
With these settings, you can easily update or regenerate the product and category URL keys, and all old URLs will automatically redirect to the new URLs.
Step 3: Enable Magento 2 Product URL Rewrite
To create a URL Rewrite for your products, follow these steps:
- From the admin panel, navigate to Catalog > Products.
- Select the product(s) for which you want to change the URL.
- Open the Search Engine Optimization section.
- Update the URL Key to the new one, ensuring that you only use lowercase letters and characters.
- Finally, click the Save button and refresh your cache.
If the product URL Rewrites are not functioning as expected, make sure to clear the cache. Once this is done, all old URLs will be redirected to the updated URLs.
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 snippet, the product object is first retrieved. Then, the getUrl() method from the
Magento\Catalog\Model\Product\Url
class is utilized to fetch the SEO-friendly URL for the product.
This approach can be customized to fit specific needs, such as obtaining the URL for a particular product by its ID or using dependency injection instead of relying on 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
If you want to review the custom URL Rewrites you've created, follow these simple steps:
- Log in to the admin panel.
- Navigate to Marketing > URL Rewrites under the SEO & Search section.
- All regenerated URL Rewrites will be displayed in a table, with the most recent ones listed at the top.
To verify the custom URL Rewrites you’ve made in Magento 2, it’s essential to check the admin panel. Magento provides an easy way to access all the URL Rewrites you've set up. This helps ensure that your custom URLs are functioning correctly and redirects are in place.
Simply log in to your Magento admin panel and navigate to Marketing > URL Rewrites under the SEO & Search section. Here, you’ll see a table displaying all the URL rewrites, with the most recently generated ones listed at the top.
This tool is especially helpful for managing your store’s SEO and keeping track of changes in product, category, or CMS page URLs.