{"id":333036,"date":"2022-05-06T07:46:52","date_gmt":"2022-05-06T07:46:52","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=333036"},"modified":"2026-02-13T12:34:54","modified_gmt":"2026-02-13T12:34:54","slug":"create-a-custom-router-in-magento2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/","title":{"rendered":"Custom Router in Magento 2"},"content":{"rendered":"\n<p>We will explore how to create and configure a custom router in Magento 2 to handle tailored URL routes effectively.<\/p>\n\n\n\n<p>To Create the Router first, need to add our custom route into the <strong>\\Magento\\Framework\\App\\RouterList<\/strong> class.<\/p>\n\n\n\n<p>For this, we use the&nbsp;<strong>di.xml&nbsp;<\/strong>file in our module.<\/p>\n\n\n\n<p>Check the Following path: <em>app\/code\/Vendor\/Module\/etc\/frontend\/di.xml<\/em><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:ObjectManager\/etc\/config.xsd&quot;&gt;\n&lt;type name=&quot;Magento\\Framework\\App\\RouterList&quot;&gt;\n    &lt;arguments&gt;\n        &lt;argument name=&quot;routerList&quot; xsi:type=&quot;array&quot;&gt;\n            &lt;item name=&quot;customRoute&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;class&quot; xsi:type=&quot;string&quot;&gt;Vendor\\Module\\Controller\\Router&lt;\/item&gt;\n                &lt;item name=&quot;disable&quot; xsi:type=&quot;boolean&quot;&gt;false&lt;\/item&gt;\n                &lt;item name=&quot;sortOrder&quot; xsi:type=&quot;string&quot;&gt;40&lt;\/item&gt;\n            &lt;\/item&gt;\n        &lt;\/argument&gt;\n    &lt;\/arguments&gt;\n&lt;\/type&gt;\n&lt;\/config&gt;<\/pre>\n\n\n\n<p>After that, now we need to create a&nbsp;<strong>custom router<\/strong>&nbsp;class.<\/p>\n\n\n\n<p>It will match the custom route name&nbsp;<code><strong>learning<\/strong><\/code>&nbsp;with the existing&nbsp;<code><strong>routing<\/strong><\/code>&nbsp;route.<\/p>\n\n\n\n<p>Check the Following path:  <em>app\/code\/Vendor\/Module\/Controller\/Router.php<\/em>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\ndeclare(strict_types=1);\n\nnamespace Vendor\\Module\\Controller;\n\nuse Magento\\Framework\\App\\Action\\Forward;\nuse Magento\\Framework\\App\\ActionFactory;\nuse Magento\\Framework\\App\\ActionInterface;\nuse Magento\\Framework\\App\\RequestInterface;\nuse Magento\\Framework\\App\\ResponseInterface;\nuse Magento\\Framework\\App\\RouterInterface;\n\n\/**\n * Class Router\n *\/\nclass Router implements RouterInterface\n{\n    \/**\n     * @var ActionFactory\n     *\/\n    private $actionFactory;\n\n    \/**\n     * @var ResponseInterface\n     *\/\n    private $response;\n\n    \/**\n     * Router constructor.\n     *\n     * @param ActionFactory $actionFactory\n     * @param ResponseInterface $response\n     *\/\n    public function __construct(\n        ActionFactory $actionFactory,\n        ResponseInterface $response\n    ) {\n        $this-&gt;actionFactory = $actionFactory;\n        $this-&gt;response = $response;\n    }\n\n    \/**\n     * @param RequestInterface $request\n     * @return ActionInterface|null\n     *\/\n    public function match(RequestInterface $request): ?ActionInterface\n    {\n        $identifier = trim($request-&gt;getPathInfo(), &#039;\/&#039;);\n\n        if (strpos($identifier, &#039;learning&#039;) !== false) {\n            $request-&gt;setModuleName(&#039;routing&#039;);\n            $request-&gt;setControllerName(&#039;index&#039;);\n            $request-&gt;setActionName(&#039;index&#039;);\n            $request-&gt;setParams(&#091;\n                &#039;first_param&#039; =&gt; &#039;first_value&#039;,\n                &#039;second_param&#039; =&gt; &#039;second_value&#039;\n            ]);\n\n            return $this-&gt;actionFactory-&gt;create(Forward::class, &#091;&#039;request&#039; =&gt; $request]);\n        }\n\n        return null;\n    }\n}<\/pre>\n\n\n\n<p>Now, we need to create our <strong>routes.xml<\/strong> file under:<\/p>\n\n\n\n<p><em>app\/code\/Vendor\/Module\/etc\/frontend\/routes.xml<\/em><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n\n&lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;\n        xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:App\/etc\/routes.xsd&quot;&gt;\n    &lt;router id=&quot;standard&quot;&gt;\n        &lt;route id=&quot;routing&quot; frontName=&quot;routing&quot;&gt;\n            &lt;module name=&quot;Vendor_Module&quot; \/&gt;\n        &lt;\/route&gt;\n    &lt;\/router&gt;\n&lt;\/config&gt;<\/pre>\n\n\n\n<p><strong>Let&#8217;s check the<\/strong> <strong>above route as an example<\/strong>, Declaring the layout handler for our new route:<\/p>\n\n\n\n<p><em>Vendor\/Module\/view\/frontend\/layout\/routing_index_index.xml<\/em><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n\n&lt;page xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;\n        xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd&quot;&gt;\n    &lt;body&gt;\n        &lt;referenceBlock name=&quot;page.main.title&quot;&gt;\n            &lt;action method=&quot;setPageTitle&quot;&gt;\n                &lt;argument translate=&quot;true&quot; name=&quot;title&quot; xsi:type=&quot;string&quot;&gt;Custom Routing Page&lt;\/argument&gt;\n            &lt;\/action&gt;\n        &lt;\/referenceBlock&gt;\n    &lt;\/body&gt;\n&lt;\/page&gt;<\/pre>\n\n\n\n<p>Creating the controller that will handle the<strong>&nbsp;<code>routing<\/code>&nbsp;route<\/strong> and will get the parameters passed by our router.<\/p>\n\n\n\n<p><em>Vendor\/Module\/Controller\/Index\/Index.php<\/em><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\ndeclare(strict_types=1);\n\nnamespace Vendor\\Module\\Controller\\Index;\n\nuse Magento\\Framework\\App\\Action\\HttpGetActionInterface;\nuse Magento\\Framework\\App\\RequestInterface;\nuse Magento\\Framework\\View\\Result\\Page;\nuse Magento\\Framework\\View\\Result\\PageFactory;\n\n\/**\n * Class Index\n *\/\nclass Index implements HttpGetActionInterface\n{\n    \/**\n     * @var PageFactory\n     *\/\n    private $pageFactory;\n\n    \/**\n      * @var RequestInterface\n      *\/\n    private $request;\n\n    \/**\n     * @param PageFactory $pageFactory\n     * @param RequestInterface $request\n     *\/\n    public function __construct(PageFactory $pageFactory, RequestInterface $request)\n    {\n        $this-&gt;pageFactory = $pageFactory;\n        $this-&gt;request = $request;\n    }\n\n    \/**\n     * @inheritdoc\n     *\/\n    public function execute()\n    {\n        \/\/ Get the params that were passed from our Router\n        $firstParam = $this-&gt;request-&gt;getParam(&#039;first_param&#039;, null);\n        $secondParam = $this-&gt;request-&gt;getParam(&#039;second_param&#039;, null);\n\n        return $this-&gt;pageFactory-&gt;create();\n    }\n}<\/pre>\n\n\n\n<p>As a result, accessing the<strong>&nbsp;<code>http:\/\/site.com\/learning<\/code><\/strong>&nbsp;route, the&nbsp;<code><strong>http:\/\/site.com\/routing\/index\/index <\/strong><\/code>route is loaded.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"656\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-from-2022-05-06-13-11-36-1200x656.png\" alt=\"Screenshot-from-2022-05-06-13-11-36\" class=\"wp-image-333077\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-from-2022-05-06-13-11-36-1200x656.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-from-2022-05-06-13-11-36-300x164.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-from-2022-05-06-13-11-36-250x137.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-from-2022-05-06-13-11-36-768x420.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-from-2022-05-06-13-11-36.png 1282w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Also, you can check out our other blog on <a href=\"https:\/\/webkul.com\/blog\/magento-2-routing\/\">Magento 2 routing<\/a> to understand how standard routing works in Magento and how URLs are mapped to controllers.<\/p>\n\n\n\n<p>That&#8217;s it. <\/p>\n\n\n\n<p>Happy Coding !!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We will explore how to create and configure a custom router in Magento 2 to handle tailored URL routes effectively. To Create the Router first, need to add our custom route into the \\Magento\\Framework\\App\\RouterList class. For this, we use the&nbsp;di.xml&nbsp;file in our module. Check the Following path: app\/code\/Vendor\/Module\/etc\/frontend\/di.xml After that, now we need to create <a href=\"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":378,"featured_media":333083,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9121],"tags":[12677,2070],"class_list":["post-333036","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-magento-2","tag-custom-router","tag-magento2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Custom Router in Magento 2 - Webkul Blog<\/title>\n<meta name=\"description\" content=\"In this post, you will learn how to create a custom router in magento2. To Create the Router first, need to add our custom route into the\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Custom Router in Magento 2 - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"In this post, you will learn how to create a custom router in magento2. To Create the Router first, need to add our custom route into the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-06T07:46:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-13T12:34:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-from-2022-05-06-13-11-36-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1282\" \/>\n\t<meta property=\"og:image:height\" content=\"701\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ashish Kumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ashish Kumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/\"},\"author\":{\"name\":\"Ashish Kumar\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/57d23646a58691882a6bd0baf5dadc21\"},\"headline\":\"Custom Router in Magento 2\",\"datePublished\":\"2022-05-06T07:46:52+00:00\",\"dateModified\":\"2026-02-13T12:34:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/\"},\"wordCount\":216,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-from-2022-05-06-13-11-36-1.png\",\"keywords\":[\"custom router\",\"Magento2\"],\"articleSection\":[\"Magento 2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/\",\"url\":\"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/\",\"name\":\"Custom Router in Magento 2 - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-from-2022-05-06-13-11-36-1.png\",\"datePublished\":\"2022-05-06T07:46:52+00:00\",\"dateModified\":\"2026-02-13T12:34:54+00:00\",\"description\":\"In this post, you will learn how to create a custom router in magento2. To Create the Router first, need to add our custom route into the\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-from-2022-05-06-13-11-36-1.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-from-2022-05-06-13-11-36-1.png\",\"width\":1282,\"height\":701,\"caption\":\"Screenshot-from-2022-05-06-13-11-36-1\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Custom Router in Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/57d23646a58691882a6bd0baf5dadc21\",\"name\":\"Ashish Kumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3ade0803c37d8f9fe88d8255d0db5361c67b2bc36a6bafa1b3e8804285115c9b?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3ade0803c37d8f9fe88d8255d0db5361c67b2bc36a6bafa1b3e8804285115c9b?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Ashish Kumar\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/ashishkumar-mg770\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Custom Router in Magento 2 - Webkul Blog","description":"In this post, you will learn how to create a custom router in magento2. To Create the Router first, need to add our custom route into the","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/","og_locale":"en_US","og_type":"article","og_title":"Custom Router in Magento 2 - Webkul Blog","og_description":"In this post, you will learn how to create a custom router in magento2. To Create the Router first, need to add our custom route into the","og_url":"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2022-05-06T07:46:52+00:00","article_modified_time":"2026-02-13T12:34:54+00:00","og_image":[{"width":1282,"height":701,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-from-2022-05-06-13-11-36-1.png","type":"image\/png"}],"author":"Ashish Kumar","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Ashish Kumar","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/"},"author":{"name":"Ashish Kumar","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/57d23646a58691882a6bd0baf5dadc21"},"headline":"Custom Router in Magento 2","datePublished":"2022-05-06T07:46:52+00:00","dateModified":"2026-02-13T12:34:54+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/"},"wordCount":216,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-from-2022-05-06-13-11-36-1.png","keywords":["custom router","Magento2"],"articleSection":["Magento 2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/","url":"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/","name":"Custom Router in Magento 2 - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-from-2022-05-06-13-11-36-1.png","datePublished":"2022-05-06T07:46:52+00:00","dateModified":"2026-02-13T12:34:54+00:00","description":"In this post, you will learn how to create a custom router in magento2. To Create the Router first, need to add our custom route into the","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-from-2022-05-06-13-11-36-1.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/05\/Screenshot-from-2022-05-06-13-11-36-1.png","width":1282,"height":701,"caption":"Screenshot-from-2022-05-06-13-11-36-1"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/create-a-custom-router-in-magento2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Custom Router in Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/57d23646a58691882a6bd0baf5dadc21","name":"Ashish Kumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3ade0803c37d8f9fe88d8255d0db5361c67b2bc36a6bafa1b3e8804285115c9b?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3ade0803c37d8f9fe88d8255d0db5361c67b2bc36a6bafa1b3e8804285115c9b?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Ashish Kumar"},"url":"https:\/\/webkul.com\/blog\/author\/ashishkumar-mg770\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/333036","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/378"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=333036"}],"version-history":[{"count":4,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/333036\/revisions"}],"predecessor-version":[{"id":526483,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/333036\/revisions\/526483"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media\/333083"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=333036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=333036"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=333036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}