OM2 Posted September 12, 2008 Share Posted September 12, 2008 I want to have a page automatically redirect to another page with no delay. I've googled and have found that I can do the following in the HTML: <META HTTP-EQUIV="Refresh" CONTENT="5; URL=autoforward_target.html"> I assume I can just change the 5 above to 0 and will have instant redirection? Or I can use PHP by using: <?php //Redirect Browser header("Location: http://www.YourSite.com/"); ?> Which is better? Thanks. OM Link to comment https://forums.phpfreaks.com/topic/123895-whats-the-best-way-to-do-an-automatic-redirect/ Share on other sites More sharing options...
ratcateme Posted September 12, 2008 Share Posted September 12, 2008 the php one is by far better as the browser has no choice but to follow your redirect you could make sure there is no other output on your page after the header() it is best to call exit() on the next line. Scott. Link to comment https://forums.phpfreaks.com/topic/123895-whats-the-best-way-to-do-an-automatic-redirect/#findComment-639609 Share on other sites More sharing options...
kirogl Posted September 12, 2008 Share Posted September 12, 2008 <META HTTP-EQUIV="Refresh" CONTENT="5; URL=autoforward_target.html"> Will load the page (so the back button will re-load the page) <?php //Redirect Browser header("Location: http://www.YourSite.com/"); ?> Won't do so. Link to comment https://forums.phpfreaks.com/topic/123895-whats-the-best-way-to-do-an-automatic-redirect/#findComment-639611 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.