In once place, I have a /Vendor/Module/etc/routes.xml, showing:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="standard">
        <route id="categories" frontName="categories">
            <module name="Vendor_Module" />

which points to a valid (as far as I can see) controller. (Index/Index, to be precisely. )

In the database, table mg_url_rewrite, "categories" is pointed towards catalog/product/view/id/.

How can I figure out where a request for www.mysite.com/categories actually goes?

My instinct says the routes.xml file, but an exact duplicate of that controller in another module shows an empty page, where .../categories actually shows the categories of the webshop. All the controller does is:

public function __construct(Context $context, PageFactory $resultPageFactory)
        $this->resultPageFactory = $resultPageFactory;

public function execute()
        $resultPage = $this->resultPageFactory->create();
        return $resultPage;

But the page doesn't even have a title, which the other (controller exact duplicate except from namespaces, and same for the routes.xml except ofcourse for the Vendor_Module, route id and frontname) module does.

However, if I manually enter the url provided by the mg_url_rewrite table, I get a 404.

  • So the actual question is, where to figure out if Magento prefers the routes defined in routes.xml or the rewrites in url_rewrite ?
    – Ekk4rd
    Commented Oct 29, 2019 at 15:33
  • Attempted to elaborate a bit more on the case, and why I think neither of those two candidates is actually loaded. Perfect answer would be a failsafe way to figure out where a certain route goes, and why.
    – Gloweye
    Commented Oct 29, 2019 at 15:42

1 Answer 1


The UrlRewrite Module. And so the urlrewrite rules use an additinoal entry inside the routerList. This entry has the sort order of 20.

    <type name="Magento\Framework\App\RouterList">
            <argument name="routerList" xsi:type="array">
                <item name="urlrewrite" xsi:type="array">
                    <item name="class" xsi:type="string">Magento\UrlRewrite\Controller\Router</item>
                    <item name="disable" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="string">20</item>

This routerlist is traversed inside the Magento\Framework\App\FrontController. The first one which matched your route is used.

Before the urlRewrite only the RouterList of the module-robots is used.

So I would guess that url-rewrite takes precendence before routes.xml, but i didn't dig further into it yet.

What checks for the routes.xml inside the frontend is not the default router. But the standard router, which is also defined in the module-store di.xml and is located in. Magento\Framework\App\Router\Base. This one has a sort order of 30 and is processed directly after the url-rewrites.

The default router which is also defined in module-store, is only for processing the no-route pages.

  • Yes, it seems so from here. But I'm still getting 404's for every rewrite destination in the table, while the .../categories request runs fine. What I'm really looking for is A) Some compiled file or B) Something I can run, which shows where Magento is actually going.
    – Gloweye
    Commented Oct 29, 2019 at 15:56
  • If you have a development system, maybe you can use xdebug to see where Magento is going. Maybe somehow the urlrewrites are disabled or modified by some module ?
    – Ekk4rd
    Commented Oct 29, 2019 at 16:02
  • "xdebug" ? Do you have a link about that? It sounds interesting, and exactly like what I'm looking for.
    – Gloweye
    Commented Oct 30, 2019 at 8:08
  • xdebug.org
    – Ekk4rd
    Commented Oct 30, 2019 at 8:58
  • I'll read up on that one. Meanwhile, I'll accept your answer, because I think that for a vast majority of others stumbling upon this question, it'll be the one they need, even if there seems to be something unsanitary going on at the installation I'm working with.
    – Gloweye
    Commented Oct 30, 2019 at 9:02

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.