Magento ver. 2.3.2

I am writing a Magento 2 module. I'm trying to re-write a CMS page URL:



I have a widget on the CMS page url-test that handles the logic of what is passed in GET['path'].

I cannot get the Router to fire at all (display the die() cmd). I've played with different values for the di sortOrder. I've tried overriding default routers. All to no avail.

I don't have a /etc/frontend/routes.xml file as I don't think I need it.


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Framework\App\RouterList">
            <argument name="routerList" xsi:type="array">
                <item name="test_router" xsi:type="array">
                    <item name="class" xsi:type="string">Me\MyModule\Controller\Router</item>
                    <item name="disable" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="string">1</item>


namespace Me\MyModule\Controller;

class Router implements \Magento\Framework\App\RouterInterface
    private $actionFactory;

   public function __construct(\Magento\Framework\App\ActionFactory $actionFactory)
        $this->actionFactory = $actionFactory;

    public function match(\Magento\Framework\App\RequestInterface $request)
        die("test Router");
        $pathInfo = $request->getPathInfo();

        return null;

1 Answer 1


die() will not work. Use logger concept.

This is the wrong files name etc/frontend/dii.xml it should be etc/frontend/di.xml.

using SortOrder value 1 is very dangerous.

In this case routing should be between 60(cms route) and 100 (default route).

See https://devdocs.magento.com/guides/v2.3/extension-dev-guide/routing.html

  • facepalm! di.xml fixed it
    – Michael
    Aug 22, 2019 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.