How to redirect to my custom route (i mean whats the best way) ?

  • You can use Url rewrite feature in magento 2. admin login >> Marketing >> Url rewrite >> add new URL rewrite. Here you can add your custom URL rewrite. – Nits Dec 21 '17 at 13:29

I think this will work for you


You can make check if home page is requested. And set your custom module and controller name from Router.php controller.

And when trying to test the module please take care of this line

$request->setModuleName('cms')->setControllerName('page')->setActionName('view')->setParam('page_id', 5);

Here 5 is the page id and some times you don't have any page in your store with page id 5 , so you have to replace it with available page id.


On the Admin panel, click Stores->Settings->Configuration->Web->General in the panel on the left. Open the Default Pages section. Change the Default Web URL to the URL of your custom module.

Your Answer

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.