return redirect code example

Example 1: javascript redirect

window.location.href = "http://mywebsite.com/home.html";

Example 2: Redirect::route('profile') and with() in laravel

// For a route with the following URI: profile/{id}

return redirect()->route('profile', [$user]);

Example 3: js redirect

window.location.href = "https://your_website.php/page2.php;
// to remove actual address from the history:
window.location.replace = "https://your_website.php/page2.php;

Example 4: Redirect::route('profile') and with() in laravel

// For a route with the following URI: profile/{id}

return redirect()->route('profile', ['id' => 1]);

Tags:

Php Example