I want to redirect to a external URL in my controller but not in the execute()
function.
This code works fine and the result is a redirect to google:
public function execute()
{
$resultRedirect = $this->resultRedirectFactory->create();
if ($this->session->isLoggedIn()) {
$resultRedirect->setUrl('https://www.google.co.uk');
return $resultRedirect;
}
)
However, this code is not working:
public function execute()
{
$this->testRedirect();
)
public function testRedirect(){
$resultRedirect = $this->resultRedirectFactory->create();
if ($this->session->isLoggedIn()) {
$resultRedirect->setUrl('https://www.google.co.uk');
return $resultRedirect;
}
}
This code doesn't redirect and leave the page blank.
What am I doing wrong?