{"id":15743,"date":"2018-05-08T12:47:13","date_gmt":"2018-05-08T10:47:13","guid":{"rendered":"https:\/\/belvg.com\/blog\/?p=15743"},"modified":"2021-02-18T11:35:41","modified_gmt":"2021-02-18T09:35:41","slug":"how-url-rewrites-work-in-magento-2","status":"publish","type":"post","link":"https:\/\/belvg.com\/blog\/how-url-rewrites-work-in-magento-2.html","title":{"rendered":"How URL Rewrites Work in Magento 2"},"content":{"rendered":"\n<p>URL Rewrites allow to display catalog URLs<em> (\/catalog\/product\/id\/123)<\/em> in a comprehensive manner <em>(\/black-tshirt.html)<\/em>. UrlRewrite Router is responsible for their processing <span style=\"color: #000000;\"><strong>(\\Magento\\UrlRewrite\\Controller\\Router)<\/strong><\/span>. It looks for a necessary URL in a database and, if found successfully, sets module, controller and action names, as well as product or category id.<\/p>\n<p><!--more--><\/p>\n<pre class=\"lang:php decode:true\">public function match(\\Magento\\Framework\\App\\RequestInterface $request)\r\n{\r\n&nbsp;&nbsp;\/\/If we're in the process of switching stores then matching rewrite\r\n&nbsp;&nbsp;\/\/rule from previous store because the URL was not changed yet from\r\n&nbsp;&nbsp;\/\/old store's format.\r\n&nbsp;&nbsp;if ($fromStore = $request-&gt;getParam('___from_store')) {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$oldStoreId = $this-&gt;storeManager-&gt;getStore($fromStore)-&gt;getId();\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$oldRewrite = $this-&gt;getRewrite(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$request-&gt;getPathInfo(),\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$oldStoreId\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($oldRewrite &amp;&amp; $oldRewrite-&gt;getRedirectType() === 0) {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/If there is a match and it's a correct URL then just\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/redirecting to current store's URL equivalent,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/otherwise just continuing finding a rule within current store.\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$currentRewrite = $this-&gt;urlFinder-&gt;findOneByData(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UrlRewrite::ENTITY_TYPE =&gt; $oldRewrite-&gt;getEntityType(),\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UrlRewrite::ENTITY_ID =&gt; $oldRewrite-&gt;getEntityId(),\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UrlRewrite::STORE_ID =&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;storeManager-&gt;getStore()-&gt;getId(),\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UrlRewrite::REDIRECT_TYPE =&gt; 0,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($currentRewrite\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;&amp; $currentRewrite-&gt;getRequestPath()\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;!== $oldRewrite-&gt;getRequestPath()\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;) {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $this-&gt;redirect(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$request,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;url-&gt;getUrl(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'',\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;['_direct' =&gt; $currentRewrite-&gt;getRequestPath()]\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;),\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OptionProvider::TEMPORARY\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;}\r\n&nbsp;&nbsp;$rewrite = $this-&gt;getRewrite(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$request-&gt;getPathInfo(),\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;storeManager-&gt;getStore()-&gt;getId()\r\n&nbsp;&nbsp;);\r\n&nbsp;&nbsp;if ($rewrite === null) {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/No rewrite rule matching current URl found, continuing with\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/processing of this URL.\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return null;\r\n&nbsp;&nbsp;}\r\n&nbsp;&nbsp;if ($rewrite-&gt;getRedirectType()) {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/Rule requires the request to be redirected to another URL\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/and cannot be processed further.\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $this-&gt;processRedirect($request, $rewrite);\r\n&nbsp;&nbsp;}\r\n&nbsp;&nbsp;\/\/Rule provides actual URL that can be processed by a controller.\r\n&nbsp;&nbsp;$request-&gt;setAlias(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UrlInterface::REWRITE_REQUEST_PATH_ALIAS,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$rewrite-&gt;getRequestPath()\r\n&nbsp;&nbsp;);\r\n&nbsp;&nbsp;$request-&gt;setPathInfo('\/' . $rewrite-&gt;getTargetPath());\r\n&nbsp;&nbsp;return $this-&gt;actionFactory-&gt;create(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\\Magento\\Framework\\App\\Action\\Forward::class\r\n&nbsp;&nbsp;);\r\n}<\/pre>\n<h2><strong><span style=\"color: #000000;\">Finding a matching URL rewrite<\/span><\/strong><\/h2>\n<p><span style=\"color: #000000;\"><strong>\\Magento\\UrlRewrite\\Controller\\Router::getRewrite<\/strong><\/span> method is responsible for searching a URL in the database.<\/p>\n<pre class=\"lang:php decode:true\">protected function getRewrite($requestPath, $storeId)\r\n{\r\n&nbsp;&nbsp;return $this-&gt;urlFinder-&gt;findOneByData([\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UrlRewrite::REQUEST_PATH =&gt; ltrim($requestPath, '\/'),\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UrlRewrite::STORE_ID =&gt; $storeId,\r\n&nbsp;&nbsp;]);\r\n}<\/pre>\n<p>This method looks for a suitable URL Rewrite in the <em>url_rewrites<\/em> table, based on the request path and current store id. If found, the object<span style=\"color: #000000;\"> <strong>\\Magento\\UrlRewrite\\Service\\V1\\Data\\UrlRewrite<\/strong><\/span> is returned.<\/p>\n<h2><strong><span style=\"color: #000000;\">Generating a URL rewrite<\/span><\/strong><\/h2>\n<p>Creation, modification and removal of URL rewrites for catalog entities are done using the module <span style=\"color: #000000;\"><strong>Magento_CatalogUrlRewrite<\/strong><\/span>. This module contains the observers responsible for the changes in the catalog entities.<\/p>\n<p>Example: processing URL Rewrite while saving the product.<\/p>\n<p>The process starts in observer method<span style=\"color: #000000;\"> <strong>\\Magento\\CatalogUrlRewrite\\Observer\\ProductProcessUrlRewriteSavingObserver<\/strong> <\/span>which is called on the event <em>catalog_product_save_after.<\/em><\/p>\n<p><em>Events.xml<\/em><\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;event name=\"catalog_product_save_after\"&gt;\r\n&nbsp;&nbsp;&lt;observer name=\"process_url_rewrite_saving\" instance=\"Magento\\CatalogUrlRewrite\\Observer\\ProductProcessUrlRewriteSavingObserver\"\/&gt;\r\n&lt;\/event&gt;<\/pre>\n<pre class=\"lang:php decode:true\">public function execute(\\Magento\\Framework\\Event\\Observer $observer)\r\n{\r\n&nbsp;&nbsp;\/** @var Product $product *\/\r\n&nbsp;&nbsp;$product = $observer-&gt;getEvent()-&gt;getProduct();\r\n&nbsp;&nbsp;if ($product-&gt;dataHasChangedFor('url_key')\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|| $product-&gt;getIsChangedCategories()\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|| $product-&gt;getIsChangedWebsites()\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|| $product-&gt;dataHasChangedFor('visibility')\r\n&nbsp;&nbsp;) {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;urlPersist-&gt;deleteByData([\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UrlRewrite::ENTITY_ID =&gt; $product-&gt;getId(),\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UrlRewrite::ENTITY_TYPE =&gt; ProductUrlRewriteGenerator::ENTITY_TYPE,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UrlRewrite::REDIRECT_TYPE =&gt; 0,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UrlRewrite::STORE_ID =&gt; $product-&gt;getStoreId()\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($product-&gt;isVisibleInSiteVisibility()) {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;urlPersist-&gt;replace($this-&gt;productUrlRewriteGenerator-&gt;generate($product));\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;}\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">After obtaining the product model from the observer, it is checked to find out whether the product&rsquo;s <\/span><i><span style=\"font-weight: 400;\">url_key<\/span><\/i><span style=\"font-weight: 400;\"> and <\/span><i><span style=\"font-weight: 400;\">visibility<\/span><\/i><span style=\"font-weight: 400;\"> have changed, as well as product&rsquo;s relation to the categories or stores.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If anything has changed, then <\/span><span style=\"color: #000000;\"><b>\\Magento\\UrlRewrite\\Model\\Storage\\DbStorage::deleteByData <\/b><\/span><span style=\"font-weight: 400;\">method is used to delete the existing URL rewrites for this product. If the product settings allow it to be displayed, the <\/span><span style=\"color: #000000;\"><b>\\Magento\\CatalogUrlRewrite\\Model\\ProductUrlRewriteGenerator::generate <\/b><\/span><span style=\"font-weight: 400;\">method is called.<\/span><\/p>\n<pre class=\"lang:php decode:true\">public function generate(Product $product, $rootCategoryId = null)\r\n{\r\n&nbsp;&nbsp;if ($product-&gt;getVisibility() == Visibility::VISIBILITY_NOT_VISIBLE) {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return [];\r\n&nbsp;&nbsp;}\r\n&nbsp;&nbsp;$storeId = $product-&gt;getStoreId();\r\n&nbsp;&nbsp;$productCategories = $product-&gt;getCategoryCollection()\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&gt;addAttributeToSelect('url_key')\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&gt;addAttributeToSelect('url_path');\r\n&nbsp;&nbsp;$urls = $this-&gt;isGlobalScope($storeId)\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;? $this-&gt;generateForGlobalScope($productCategories, $product, $rootCategoryId)\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: $this-&gt;generateForSpecificStoreView($storeId, $productCategories, $product, $rootCategoryId);\r\n&nbsp;&nbsp;return $urls;\r\n}<\/pre>\n<p><b><\/b><span style=\"font-weight: 400;\">After checking the product visibility, this method gets a collection of all the categories associated with the product, and then, depending on the current scope, calls the <\/span><span style=\"color: #000000;\"><b>\\Magento\\CatalogUrlRewrite\\Model\\ProductUrlRewriteGenerator::generateForGlobalScope<\/b><\/span><span style=\"font-weight: 400;\"> or <\/span><span style=\"color: #000000;\"><b>\\Magento\\CatalogUrlRewrite\\Model\\ProductUrlRewriteGenerator::generateForSpecificStoreView <\/b><\/span><span style=\"font-weight: 400;\">methods.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Let&rsquo;s take a look at the situation with the global scope.<\/span><\/p>\n<pre class=\"lang:php decode:true\">protected function generateForGlobalScope($productCategories, $product = null, $rootCategoryId = null)\r\n{\r\n&nbsp;&nbsp;return $this-&gt;getProductScopeRewriteGenerator()-&gt;generateForGlobalScope(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$productCategories,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$product,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$rootCategoryId\r\n&nbsp;&nbsp;);\r\n}\r\npublic function generateForGlobalScope($productCategories, Product $product, $rootCategoryId = null)\r\n{\r\n&nbsp;&nbsp;$productId = $product-&gt;getEntityId();\r\n&nbsp;&nbsp;$mergeDataProvider = clone $this-&gt;mergeDataProviderPrototype;\r\n&nbsp;&nbsp;foreach ($product-&gt;getStoreIds() as $id) {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!$this-&gt;isGlobalScope($id) &amp;&amp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;!$this-&gt;storeViewService-&gt;doesEntityHaveOverriddenUrlKeyForStore(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$id,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$productId,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Product::ENTITY\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)) {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$mergeDataProvider-&gt;merge(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;generateForSpecificStoreView($id, $productCategories, $product, $rootCategoryId)\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;}\r\n&nbsp;&nbsp;return $mergeDataProvider-&gt;getData();\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">For each of the available stores, the <\/span><span style=\"color: #000000;\"><b>\\Magento\\CatalogUrlRewrite\\Model\\ProductScopeRewriteGenerator::generateForGlobalScope<\/b><\/span><span style=\"font-weight: 400;\"> method checks to see if the <\/span><i><span style=\"font-weight: 400;\">url_key<\/span><\/i><span style=\"font-weight: 400;\"> of the product duplicates an existing one. If <\/span><i><span style=\"font-weight: 400;\">url_key<\/span><\/i><span style=\"font-weight: 400;\"> is unique, it calls the generation of the URL rewrite for this store. After creating URL rewrites for all the existing stores, they are combined into a common array using the <span style=\"color: #000000;\">\\<\/span><\/span><span style=\"color: #000000;\"><b>Magento\\UrlRewrite\\Model\\MergeDataProvider<\/b><\/span><span style=\"font-weight: 400;\"> class object.<\/span><\/p>\n<pre class=\"lang:php decode:true\"><b>public function <\/b>generateForSpecificStoreView($storeId, $productCategories, Product $product, $rootCategoryId = <b>null<\/b>)\r\n{\r\n&nbsp;&nbsp;$mergeDataProvider = clone $this-&gt;mergeDataProviderPrototype;\r\n&nbsp;&nbsp;$categories = [];\r\n&nbsp;&nbsp;foreach ($productCategories as $category) {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!$this-&gt;isCategoryProperForGenerating($category, $storeId)) {\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ category should be loaded per appropriate store if category's URL key has been changed\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$categories[] = $this-&gt;getCategoryWithOverriddenUrlKey($storeId, $category);\r\n&nbsp;&nbsp;}\r\n&nbsp;&nbsp;$productCategories = $this-&gt;objectRegistryFactory-&gt;create(['entities' =&gt; $categories]);\r\n&nbsp;&nbsp;$mergeDataProvider-&gt;merge(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;canonicalUrlRewriteGenerator-&gt;generate($storeId, $product)\r\n&nbsp;&nbsp;);\r\n&nbsp;&nbsp;$mergeDataProvider-&gt;merge(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;categoriesUrlRewriteGenerator-&gt;generate($storeId, $product, $productCategories)\r\n&nbsp;&nbsp;);\r\n&nbsp;&nbsp;$mergeDataProvider-&gt;merge(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;currentUrlRewritesRegenerator-&gt;generate(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$storeId,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$product,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$productCategories,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$rootCategoryId\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)\r\n&nbsp;&nbsp;);\r\n&nbsp;&nbsp;$mergeDataProvider-&gt;merge(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;anchorUrlRewriteGenerator-&gt;generate($storeId, $product, $productCategories)\r\n&nbsp;&nbsp;);\r\n&nbsp;&nbsp;$mergeDataProvider-&gt;merge(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;currentUrlRewritesRegenerator-&gt;generateAnchor(\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$storeId,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$product,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$productCategories,\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$rootCategoryId\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)\r\n&nbsp;&nbsp;);\r\n&nbsp;&nbsp;return $mergeDataProvider-&gt;getData();\r\n}<\/pre>\n<p><span style=\"color: #000000;\"><span style=\"font-weight: 400;\">The method&nbsp;<strong>generateForSpecificStoreView<\/strong>&nbsp;of class&nbsp;<\/span><b>\\Magento\\CatalogUrlRewrite\\Model\\ProductScopeRewriteGenerator<\/b><span style=\"font-weight: 400;\">&nbsp;gets a specific <\/span><i><span style=\"font-weight: 400;\">url_key<\/span><\/i><span style=\"font-weight: 400;\"> for each product category of the current store, and then uses the <\/span><b>\\Magento\\UrlRewrite\\Model\\MergeDataProvider<\/b><span style=\"font-weight: 400;\"> instance to combine the results of several calls:<\/span><\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"color: #000000;\"><b>\\Magento\\CatalogUrlRewrite\\Model\\Product\\CanonicalUrlRewriteGenerator::generate<\/b><span style=\"font-weight: 400;\"> &mdash; creates URL Rewrite not containing categories;<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"color: #000000;\"><b>\\Magento\\CatalogUrlRewrite\\Model\\Product\\CategoriesUrlRewriteGenerator::generate<\/b><span style=\"font-weight: 400;\"> &mdash; creates URL Rewrite including possible categories;<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"color: #000000;\"><b>\\Magento\\CatalogUrlRewrite\\Model\\Product\\CurrentUrlRewritesRegenerator::generate<\/b><span style=\"font-weight: 400;\"> &mdash; creates URL Rewrites considering the existing URL rewrites for this entity (e.g. custom URL rewrites);<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"color: #000000;\"><b>\\Magento\\CatalogUrlRewrite\\Model\\Product\\AnchorUrlRewriteGenerator::generate<\/b><span style=\"font-weight: 400;\"> &mdash; generates URL Rewrites for anchor categories;<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400; color: #000000;\">The method<strong>&nbsp;generateAnchor <\/strong>of class<strong>&nbsp;\\Magento\\CatalogUrlRewrite\\Model\\Product\\CurrentUrlRewritesRegenerator<\/strong> &mdash; generates URL Rewrites for anchor categories considering the existing URL rewrites.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">The result of all these methods is combined into an array and returned to the <\/span><span style=\"color: #000000;\"><b>\\Magento\\UrlRewrite\\Model\\Storage\\AbstractStorage::replace<\/b><\/span><span style=\"font-weight: 400;\"> method, which is responsible for the URL Rewrites persistence.<\/span><\/p>\n<p>This is how URL rewrites work in Magento 2. You can also check out the <a href=\"https:\/\/belvg.com\/blog\/url-rewrites-in-magento-1-and-magento-2-developer-certification-exam.html\">comparison between Magento 1 and Magento 2 URL rewrites<\/a>, which is among the topics of the developer certification exam.<\/p>\n<div class=\"module_in_content_container\"><a href=\"https:\/\/store.belvg.com\/\" class=\"link_to_module\" target=\"_blank\" rel=\"noopener\"><\/a><div class=\"module_content\"><img src=\"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2016\/05\/Magento-store.belvg_.com_.png\" width=\"481\" height=\"480\" alt=\"Magento store.belvg.com\" class=\"module_image\" title=\"How URL Rewrites Work in Magento 2\"><div class=\"module_content_part\"><h3 class=\"title\">BelVG Magento Store<\/h3><p class=\"module_content_text\">Take your online store to the next level with BelVG extensions<\/p><a href=\"https:\/\/store.belvg.com\/\" class=\"link_2_to_module\" target=\"_blank\" style=\"display:inline-block\" rel=\"noopener\"><span class=\"read-more\">Visit the store<\/span><\/a><\/div><\/div><\/div>\n<p>Need <a href=\"https:\/\/belvg.com\/magento-development\" target=\"_blank\" rel=\"noopener\">experienced<\/a> Magento developers? BelVG can help!<\/p>\n\n","protected":false},"excerpt":{"rendered":"Working with URL Rewrites in Magento 2","protected":false},"author":82,"featured_media":15762,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_acf_changed":false,"footnotes":""},"categories":[474,389,524],"tags":[],"class_list":["post-15743","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-ecommerce","category-magento2-development","category-magento-speed-optimization","post_format-post-format-image"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"How to use URL rewrites in Magento 2: a guide to the processes of finding a matching URL rewrite and generating a URL rewrite.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Andrey Litvin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/belvg.com\/blog\/how-url-rewrites-work-in-magento-2.html\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-url-rewrites-work-in-magento-2.html#article\",\"name\":\"Utilizing URL Rewrites in Magento 2 | BelVG Blog\",\"headline\":\"How URL Rewrites Work in Magento 2\",\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/05\\\/How-URL-Rewrites-Work-in-Magento-2.jpg\",\"width\":770,\"height\":433},\"datePublished\":\"2018-05-08T12:47:13+02:00\",\"dateModified\":\"2021-02-18T11:35:41+02:00\",\"inLanguage\":\"en-US\",\"commentCount\":5,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-url-rewrites-work-in-magento-2.html#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-url-rewrites-work-in-magento-2.html#webpage\"},\"articleSection\":\"ECOMMERCE, Magento 2 Development, Magento Speed Optimization, Image\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-url-rewrites-work-in-magento-2.html#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"name\":\"Magento 2 Development\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"position\":2,\"name\":\"Magento 2 Development\",\"item\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-url-rewrites-work-in-magento-2.html#listItem\",\"name\":\"How URL Rewrites Work in Magento 2\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-url-rewrites-work-in-magento-2.html#listItem\",\"position\":3,\"name\":\"How URL Rewrites Work in Magento 2\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/category\\\/magento2-development#listItem\",\"name\":\"Magento 2 Development\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin\",\"name\":\"Andrey Litvin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-url-rewrites-work-in-magento-2.html#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e1a6e3c80cb940fddb65016d94b015cd951b4a8a9cd7227565131f28ea95c7a0?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Andrey Litvin\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-url-rewrites-work-in-magento-2.html#webpage\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-url-rewrites-work-in-magento-2.html\",\"name\":\"Utilizing URL Rewrites in Magento 2 | BelVG Blog\",\"description\":\"How to use URL rewrites in Magento 2: a guide to the processes of finding a matching URL rewrite and generating a URL rewrite.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-url-rewrites-work-in-magento-2.html#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/author\\\/andrey-litvin#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/05\\\/How-URL-Rewrites-Work-in-Magento-2.jpg\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-url-rewrites-work-in-magento-2.html\\\/#mainImage\",\"width\":770,\"height\":433},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/how-url-rewrites-work-in-magento-2.html#mainImage\"},\"datePublished\":\"2018-05-08T12:47:13+02:00\",\"dateModified\":\"2021-02-18T11:35:41+02:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/belvg.com\\\/blog\\\/\",\"name\":\"BelVG Blog\",\"description\":\"Magento and Prestashop articles\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/belvg.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Utilizing URL Rewrites in Magento 2 | BelVG Blog","description":"How to use URL rewrites in Magento 2: a guide to the processes of finding a matching URL rewrite and generating a URL rewrite.","canonical_url":"https:\/\/belvg.com\/blog\/how-url-rewrites-work-in-magento-2.html","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/belvg.com\/blog\/how-url-rewrites-work-in-magento-2.html#article","name":"Utilizing URL Rewrites in Magento 2 | BelVG Blog","headline":"How URL Rewrites Work in Magento 2","author":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/05\/How-URL-Rewrites-Work-in-Magento-2.jpg","width":770,"height":433},"datePublished":"2018-05-08T12:47:13+02:00","dateModified":"2021-02-18T11:35:41+02:00","inLanguage":"en-US","commentCount":5,"mainEntityOfPage":{"@id":"https:\/\/belvg.com\/blog\/how-url-rewrites-work-in-magento-2.html#webpage"},"isPartOf":{"@id":"https:\/\/belvg.com\/blog\/how-url-rewrites-work-in-magento-2.html#webpage"},"articleSection":"ECOMMERCE, Magento 2 Development, Magento Speed Optimization, Image"},{"@type":"BreadcrumbList","@id":"https:\/\/belvg.com\/blog\/how-url-rewrites-work-in-magento-2.html#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","position":1,"name":"Home","item":"https:\/\/belvg.com\/blog\/","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","name":"Magento 2 Development"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","position":2,"name":"Magento 2 Development","item":"https:\/\/belvg.com\/blog\/category\/magento2-development","nextItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/how-url-rewrites-work-in-magento-2.html#listItem","name":"How URL Rewrites Work in Magento 2"},"previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/how-url-rewrites-work-in-magento-2.html#listItem","position":3,"name":"How URL Rewrites Work in Magento 2","previousItem":{"@type":"ListItem","@id":"https:\/\/belvg.com\/blog\/category\/magento2-development#listItem","name":"Magento 2 Development"}}]},{"@type":"Organization","@id":"https:\/\/belvg.com\/blog\/#organization","name":"BelVG Blog","description":"Magento and Prestashop articles","url":"https:\/\/belvg.com\/blog\/"},{"@type":"Person","@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author","url":"https:\/\/belvg.com\/blog\/author\/andrey-litvin","name":"Andrey Litvin","image":{"@type":"ImageObject","@id":"https:\/\/belvg.com\/blog\/how-url-rewrites-work-in-magento-2.html#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/e1a6e3c80cb940fddb65016d94b015cd951b4a8a9cd7227565131f28ea95c7a0?s=96&d=mm&r=g","width":96,"height":96,"caption":"Andrey Litvin"}},{"@type":"WebPage","@id":"https:\/\/belvg.com\/blog\/how-url-rewrites-work-in-magento-2.html#webpage","url":"https:\/\/belvg.com\/blog\/how-url-rewrites-work-in-magento-2.html","name":"Utilizing URL Rewrites in Magento 2 | BelVG Blog","description":"How to use URL rewrites in Magento 2: a guide to the processes of finding a matching URL rewrite and generating a URL rewrite.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/belvg.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/belvg.com\/blog\/how-url-rewrites-work-in-magento-2.html#breadcrumblist"},"author":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"creator":{"@id":"https:\/\/belvg.com\/blog\/author\/andrey-litvin#author"},"image":{"@type":"ImageObject","url":"https:\/\/belvg.com\/blog\/wp-content\/uploads\/2018\/05\/How-URL-Rewrites-Work-in-Magento-2.jpg","@id":"https:\/\/belvg.com\/blog\/how-url-rewrites-work-in-magento-2.html\/#mainImage","width":770,"height":433},"primaryImageOfPage":{"@id":"https:\/\/belvg.com\/blog\/how-url-rewrites-work-in-magento-2.html#mainImage"},"datePublished":"2018-05-08T12:47:13+02:00","dateModified":"2021-02-18T11:35:41+02:00"},{"@type":"WebSite","@id":"https:\/\/belvg.com\/blog\/#website","url":"https:\/\/belvg.com\/blog\/","name":"BelVG Blog","description":"Magento and Prestashop articles","inLanguage":"en-US","publisher":{"@id":"https:\/\/belvg.com\/blog\/#organization"}}]}},"aioseo_meta_data":{"post_id":"15743","title":"Utilizing URL Rewrites in Magento 2 | #site_title","description":"How to use URL rewrites in Magento 2: a guide to the processes of finding a matching URL rewrite and generating a URL rewrite.","keywords":null,"keyphrases":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_image_url":null,"twitter_title":null,"twitter_description":null,"schema_type":"default","schema_type_options":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null,"created":"2026-11-03 18:37:09","updated":"2026-11-03 18:37:09"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/belvg.com\/blog\/category\/magento2-development\" title=\"Magento 2 Development\">Magento 2 Development<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHow URL Rewrites Work in Magento 2\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/belvg.com\/blog\/"},{"label":"Magento 2 Development","link":"https:\/\/belvg.com\/blog\/category\/magento2-development"},{"label":"How URL Rewrites Work in Magento 2","link":"https:\/\/belvg.com\/blog\/how-url-rewrites-work-in-magento-2.html"}],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/15743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/users\/82"}],"replies":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/comments?post=15743"}],"version-history":[{"count":1,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/15743\/revisions"}],"predecessor-version":[{"id":21802,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/posts\/15743\/revisions\/21802"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media\/15762"}],"wp:attachment":[{"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/media?parent=15743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/categories?post=15743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/belvg.com\/blog\/wp-json\/wp\/v2\/tags?post=15743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}