Web Hosting Talk







View Full Version : scheduled redirects


WebEnzyme
03-17-2005, 12:51 AM
Hi

Redirecting page A to another page B automatically for maybe an hour every 12 hours. is this possible?

I have a website and i want to display a special page announcement every now and then for sometime and i might not be able to do that manually all the time

any tips or ideas?

thanks!

X-TechMedia
03-17-2005, 05:56 AM
You could use a bit of PHP in the top of your index file


if (date("G") == 14) {
header("location: htp://www.thissite.com/");
}


so as long as it's 2:00pm then the site would redirect to another site.

WebEnzyme
03-17-2005, 08:02 AM
but how can i add more times or specify a more precise time scale?

lets say i want both: from 2:30 to 3:30 and from 6 to 7

and are these times according to my own time zone, or would every user experience this different according to their time zone?

thnaks a lot

X-TechMedia
03-17-2005, 09:34 AM
if ( ((time() >= strtotime("2:00pm")) && (time() <= strtotime("2:30pm"))) || ((time() >= strtotime("6:00pm")) && (time() <= strtotime("7:00pm"))) ) {
header("location: htp://www.thislink.com");
}


That would do the times specified, im sure you could use arrays and a loop with it quite easily though

Forget to mention, these times are all based on the time on your server

WebEnzyme
03-18-2005, 12:19 AM
hi again

actually it doesnt seem to be working. nothing is happening. i put the code before any single word in a certain page and its not redirecting. of coruse i paid attention to the time.

any idea? and could this be done in javascript?

i would like to actually do this for a forum. but i even tried with a regular .php page and it didnt redirect

X-TechMedia
03-18-2005, 05:35 AM
Hmmm....strange
I just tried it, and it works for me?

did you change the address it redirects to?
The one in the code won't work htp:// instead of http://

WebEnzyme
03-18-2005, 10:25 AM
wonderful its working now. i didnt see that htp:// !

thanks a lot :]