This is a simple fix for a common issue creating custom adminhtml controllers for the first time in our Magento 2.x project.

Let’s asume you created a routes.xml file and a controller, both on the adminhtml scope, but when type the URL on your browser, you are redirected to dashboard.

That is because Magento use “secret key” for each request on the adminhtml. You only need to disable that option from the backend.

Go to:

Stores => Configuration => Advanced => Admin => Security => Add Secret Key to URLs.

Then you should be able to reach your action.

Leave a comment