How to make a redirect in php and javascript?

Member

by addison , in category: Third Party Scripts , 7 months ago

How to make a redirect in php and javascript?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lizzie , 6 months ago

@addison 

In PHP, you can use the header() function to redirect to a different page. Here is an example:

1
2
3
4
5
<?php
// Redirect to another page
header("Location: http://www.example.com");
exit();
?>


In JavaScript, you can use the window.location object to redirect to a different page. Here is an example:

1
2
// Redirect to another page
window.location = "http://www.example.com";


Both of these methods will instantly redirect the user to the specified URL.

Related Threads:

How to redirect after 5 seconds in PHP?
How to make a loop with a timer in canvas in javascript?
How to use multiple redirect using one javascript?
How to make a hover effect in javascript?
How to make iframe redirect with cookies?
How to make a redirect uri in haproxy?