Magento url redirect from a Controller

 
<?php
 
namespace Imran\Test\Controller\Index;
 
use \Magento\Framework\App\Action\Action;
 
class Index extends Action
{
    /**
     * @var  \Magento\Framework\View\Result\Page
     */
    protected $resultPageFactory;
 
    /**
     * @param \Magento\Framework\App\Action\Context $context
     */
    public function __construct(\Magento\Framework\App\Action\Context $context,
                                    \Magento\Framework\View\Result\PageFactory $resultPageFactory)
    {
        parent::__construct($context);
        $this->resultPageFactory = $resultPageFactory;
        $this->resultRedirectFactory->create()->setUrl('https://www.someurl.com');
    }
}

Leave a Reply