I want to create the controller which get the parameter like
http://example.com/manufacturerpages/index/id/497
When I do this, It goes to 404 error plus I am also not able to get the id in controller by using this code
$mId = (int) $this->getRequest()->getParam('id', false);
I don't need the solution like
http://example.com/manufacturerpages/index?id/497
Because I have to use it in URL Rewrite so in that case, it is not working
Any help, experience and knowledge sharing would be appreciated.
Best Answer
As I worked on it, got the solution. First you need the create the
di.xml
to your module. As it is frontend custom router so you have to define it inetc\frontend
. Type name for Router list addition isMagento\Framework\App\RouterList
Path should be like:
app\code\Vendor\Module\etc\frontend\di.xml
Then you need to add the
Router.php
in your module filePath should be like:
app\code\Vendor\Module\Controller\Router.php
. You need to definematch
function in your router file after than you can forward the request from wherever you wantAs my work belongs to
URL Rewrite
. So I made a new URL Rewrite and define request path and target path for that. So when user hit the request it come on the match function then you will redirect it to request pathI hope this will help