I want to create the controller which get the parameter like


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


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.

  • you should create your own route fro that to work
    – fmsthird
    Apr 29, 2019 at 8:24
  • I already know that, what I need to know that how we do that? If you have the relevant example or experience then share it on answer Apr 29, 2019 at 8:45
  • okay but using custom route. I will post below
    – fmsthird
    Apr 29, 2019 at 9:10
  • ok but don't post the general addition of custom route which I can easily access from google. It must have the part of parameter addition and use it on controller (relevant) Apr 29, 2019 at 9:13
  • 6
    @magefms I always appreciate relevant knowledge sharing by upvoting as you already know because you also posted an answer before on my other posts as well. I don't know why there is too much downvote but to be very honest, Answer is not up to the mark and relevant. So never mind, keep coding thanks :) Apr 29, 2019 at 10:06

2 Answers 2


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 in etc\frontend. Type name for Router list addition is Magento\Framework\App\RouterList

Path should be like: app\code\Vendor\Module\etc\frontend\di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Framework\App\RouterList">
            <argument name="routerList" xsi:type="array">
                <item name="customRouteForBlog" xsi:type="array">
                    <item name="class" xsi:type="string">Naheed\Manufacturerpages\Controller\Router</item>
                    <item name="disable" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="string">20</item>

Then you need to add the Router.php in your module file

Path should be like: app\code\Vendor\Module\Controller\Router.php. You need to define match function in your router file after than you can forward the request from wherever you want

class Router implements \Magento\Framework\App\RouterInterface
    public function  match(\Magento\Framework\App\RequestInterface $request) {

As 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 path

I hope this will help


You can try by below method. Queries will be passed after appending ?.

use Magento\Framework\UrlInterface;

UrlInterface $urlBuilder

$this->_urlBuilder = $urlBuilder;

$queryParams = [
    'oid' => base64_encode($data['order_id']),
    'cid' => base64_encode($data['customer_id'])

$this->_urlBuilder->getUrl('controller/index', ['_current' => true,'_use_rewrite' => true, '_query' => $queryParams]);
  • I don't get it, did you read my question completely? just asking, because I think you gave me answer to something else. I already solved this problem and shared the answer as well. Still thanks for your answer. May 2, 2019 at 7:19
  • For your effort and time +1. May 22, 2019 at 4:45

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.