I'm trying to create an admin route and the directories are:


the code is

namespace Mastering\SampleModule\Controller\Adminhtml\Index;

use Magento\Framework\Controller\ResultFactory;

class Index extends \Magento\Backend\App\Action
    public function execute()
        /** @var \Magento\Framework\Controller\Result\Raw $result */
        $result = $this->resultFactory->create(ResultFactory::TYPE_RAW);
        $result->setContents('Hello Admins!');
        return $result;

and my routes.xml directory

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="admin">
        <route id="mastering" frontName="mastering">
            <module name="Mastering_SampleModule"/>

and after that I went to admin panel and disabled security keys. now i go to myhost/admin/mastering

and it returns

Magento Admin admin 404 Error Page not found.

my magento version is 2.4

New contributor
Ammar Joma is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.





where RouterName = name which you specified in routes.xml

Your Answer

Ammar Joma is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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