I tried below code but page is not redirecting

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$redirect = $objectManager->get('\Magento\Framework\App\Response\Http');
$redirect->setRedirect('Your path....');

Please, anyone help me.

  • what issue your are facing ? – Yogesh Feb 15 '18 at 14:24

You need to define constructor for it.

Below code is working for me.


namespace Vendor\AdvancedReviews\Model\Plugin;

class Form
protected $_responseFactory;
protected $_url;

public function __construct(

    \Magento\Framework\App\ResponseFactory $responseFactory,
    \Magento\Framework\UrlInterface $url
) {
    $this->_responseFactory = $responseFactory;
    $this->_url = $url;

public function afterexecute(\Magento\Customer\Controller\Adminhtml\Group\Save $save,$result)
           // Do your stuff

$CustomRedirectionUrl = $this->_url->getUrl('*/*/');
  • It's not working. I need redirect is working .phtml file ? – venkata prasad Feb 15 '18 at 10:30

If you are doing custom redirection from Controller, you can use the below code:

$url = $this->_url->getUrl('customer/account/create'); //custom path URL

If you want to do custom redirection using object manager, you can use the below code:

$response = $this->_objectManager->get("\Magento\Framework\App\ResponseInterface");
$url = $this->_objectManager->get("\Magento\Framework\UrlInterface");

$url = $this->_url->getUrl('customer/account/create'); //custom path URL
  • what is _url? i get error Undefined property – jibin george Dec 30 '19 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.