Jump to content

What's the best way to do an automatic redirect?


OM2

Recommended Posts

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

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.

<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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.