Answer the question
In order to leave comments, you need to log in
How to make a delayed redirect in Laravel?
A trivial task, but I can not solve it for two hours already. There is a simple page with a link.
Task: when you click on the link, a certain page opens, let's call it 'test' , from which a redirect occurs to the required page, let's call it 'final'. On the 'test' page, we display a simple string "You are being redirected..." and with a delay of 2-3 seconds we redirect to 'final'.
As I see :
routes.php
Route::get( '/test' ,'Production\[email protected]');
public function TestPage()
{
view('production.pages.home.test');
sleep(3);
Redirect::to('https://final.com', 301);
}
return
, but then one thing will be done - either displaying the page or redirecting. Answer the question
In order to leave comments, you need to log in
Either you do a 301 redirect, or you show a page that has a meta/js redirect and it won't be a 301 redirect anymore.
There is no third.
view('production.pages.home.test');
sleep(3);
Redirect::to('https://final.com', 301);
Redirect already in the browser using JS or meta http-equiv="refresh". There already and set the delay.
This is done using js on the page itself. and using sleep() stops the execution of the php script for a while and in the end you won't even get the page, because you did a redirect at the header http headers level with php.
nimishprabhu.com/header-php-refresh-redirect-locat...
https://laravel.com/docs/5.1/responses#attaching-h
... .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question