I am a beginner in Magento Magento 2. I'm trying to learn how to develop module for mage but I have problem with custom routing in module.

Here's what I've done:

  1. I cloned from their repo and installed by the composer.
  2. I downloaded the 'sample-module-newpage' from the repo https://github.com/magento/magento2-samples
  3. I placed sample-module-newpage in the app/code/Magento/sample-module-newpage.
  4. Then I enable the module with command: enable Magento_SampleNewPage
  5. Then I was executed command magento setup:update

Now couple things:

  • In Magento backoffice stores -> configuration -> advanced -> advanced in section Disable Modules Output I can see that Magento_SampleNewPage is enabled

  • I disabled Magento cache

  • I'm not sure if it should look like this but to the admin panel I get through exaple.com/index.php/admin

  • After installation Magento wasn't able to load css and js depedencies because of wrong file path. To fix this I was run two commands magento setup:static-content:deploy and magento indexer:reindex

My problem

I'm not able to access example page which is created by my module. Readme says that page can be accessed at /newpage but I'm getting apache 404. I've tried also at /index.php/newpage but I'm getting magento error that page doesn't exists.

What I'm doing wrong?

  • Did you try to clean up var/ folder ? Feb 15, 2016 at 15:33
  • If u mean deleting everyting from var/cache then yes. And still the same. Feb 15, 2016 at 15:40
  • You can feel free to delete all files inside var folder. Just keep .htacess as is. Feb 15, 2016 at 16:32
  • Your Admin URL should not include index.php. Did you enable Apache rewrites? Feb 15, 2016 at 22:54
  • Ok, everything work's fine now. I moved from Nginx to Apache with mod-rewrite. Clearing var folder after adding module to magento is not enough. After adding new module to magento 2, I am executing folowing commands php bin/magento setup:upgrade then I am clearing var folder and at the end I'm setting chmods agin with following commands sudo chmod -R 777 var sudo chmod -R 777 app/etc sudo chmod -R 777 pub. Thank you all for your help. Feb 22, 2016 at 10:40

2 Answers 2






The module frontname is newpage definded in /etc/frontend/routes.xml line 10.

The controller lives in the index folder with the name index so you should add index/index to the url.

URL Syntax

{magento-base-url}/index.php/{route frontName}/{controller folder}/{controller class}/

More info: http://inchoo.net/magento-2/magento-2-controllers/


Try to push module code to app/code/Magento/SampleNewPage folder

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.