Minecrafter Alex Minecrafter Alex - 1 year ago 109
PHP Question

How to redirect twice in php or javascript?

I want to make a script in php or javascript that will redirect the user to a page,wait x seconds and then redirect to another site.
Let's see an example

  1. User acces www.abcdefg.com/Redirect.php

  2. User is redirected to another site A

  3. Script is waiting x seconds

  4. User si automatically redireced to site B

Note: All these stuff must be made throught a single script Redirect.php
It musn't open new tabs,everything is running on one window.

What i know.
I gave found that the header tag can be use to redirect you to someting.But when we are redirected ,we cancel the script execution,because we acces another site.

So how can I do a l duble redirect throught a site??
Thank you verry much and sorry for my bad englesh.
I hope someone can help me.

Answer Source

On your first page you should redirect to a special "redirect.php" page like that:

header('location: redirect.php?to=http://www.newsite.com');

This will take you to http://www.yoursite.com/redirect.php?to=http://www.newsite.com

And then your "redirect.php" page could be:

header('location: ' + $_GET['to']);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download