0

My target URL is: http://mylocalhost/devis/customer/printPdf

But it triggers a 404 and I can't find why

I have my frontend router

app/code/FT/Devis/etc/frontend/routex.xml

<?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="standard"> <route id="devis" frontName="devis"> <module name="FT_Devis" /> </route> </router> </config> 

And I have my Controller

app/code/FT/Devis/Controller/Customer/PrintPdf.php

And of course, this class extends the action to have his own construct and execute method.

Can't figure out why this routes is not working. Moreover, it was something who worked before I think.

2
  • routex.xml is an incorrect file name (or is it a typo?) Commented Aug 31, 2020 at 8:23
  • 1
    typo, issue is fixed Commented Aug 31, 2020 at 12:05

1 Answer 1

0

Step 1: Create routes.xml file. File: app/code/Vendor/HelloWorld/etc/frontend/routes.xml

<?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="standard"> <route frontName="helloworld" id="helloworld"> <module name="Vendor_HelloWorld"/> </route> </router> </config> 

Step 2: Create controller file File: app/code/Vendor/HelloWorld/Controller/Index/Index.php

<?php namespace Vendor\HelloWorld\Controller\Index; class Index extends \Magento\Framework\App\Action\Action { protected $_pageFactory; public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Framework\View\Result\PageFactory $pageFactory) { $this->_pageFactory = $pageFactory; return parent::__construct($context); } public function execute() { echo'magentocontroller'; exit; return $this->_pageFactory->create(); } } 

Browse http://<yourhost.com>/helloworld/index/index

1
  • Actually I've been a little too fast on conclusion, I was hitting my controller but a redirection was hidden in the controller. So it wasn't a real 404 but a redirect from the controller to a 404. Issue is fixed. Commented Aug 31, 2020 at 12:06

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.