0

I have created a script file in root folder of the magento as like below

<?php error_reporting(E_ALL); use \Magento\Framework\App\Bootstrap; require __DIR__ . '../../app/bootstrap.php'; $bootstrap = Bootstrap::create(BP, $_SERVER); $obj = $bootstrap->getObjectManager(); $state = $obj->get('Magento\Framework\App\State'); $state->setAreaCode('frontend'); $resource = $obj->get('Magento\Framework\App\ResourceConnection'); $connection = $resource->getConnection(); $response = $_REQUEST; /* echo '<pre>'; print_r($response);die;*/ $unique_code= $response['unique_code']; $this->_redirect("custom/services/custompage", ['unique_code' => $unique_code]); 

In above code I am trying to redirect to my custom controller, with parameter,

but the above code is not working. Can anyone tell me how can we redirect to controller with parameter.

Thanks!!

1 Answer 1

1

You can use this below script in your root file :

<?php error_reporting(1); ini_set('max_execution_time', 0); use \Magento\Framework\App\Bootstrap; require __DIR__ . '/app/bootstrap.php'; $bootstrap = Bootstrap::create(BP, $_SERVER); $objectManager = $bootstrap->getObjectManager(); $state = $objectManager->get('\Magento\Framework\App\State'); $state->setAreaCode('frontend'); $urlInterface = $objectManager->get('Magento\Framework\UrlInterface'); $params = ['name' => 'Rohan']; $url = $urlInterface->getUrl('custom/index/index', $params); header('Location:' . $url);die(); 

Then, you can get params value in your controller :

print_r($this->getRequest()->getParams()); 

Hope, It will helpful for you !!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.