I want to redirect my view to the homepage after data submitted in a custom form


This code leads to redirection, for now, please help

Also is it possible to get a delay of 5-10 sec in redirection

  • Why you need delay?
    – Amit Bera
    Commented Jun 11, 2019 at 8:07

3 Answers 3


try this code:


if you need to delay, use function sleep() of php


You can directly use below code in Action controller


For delay in redirect, you can use sleep(5);

Please let me know if you find any difficulty.


There is a best example for redirect page after some time is customer logout.

You can use below code to redirect specific page.

$resultRedirect->setPath('Your redirect path');

For delay logic, you have to use the below script.

], function($){

    $($.mage.redirect("<?= $block->escapeJs($block->escapeUrl($block->getUrl())) ?>", "assign", 5000));


Note: Above code is not tested i have just share logic. you have to change or apply logic as per your requirement.

I hope it helps!

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.