Jump to content
facnani

php - verifica daca pagina A e ok inainte sa faca redirect

Recommended Posts

Posted

Cum fac un fisier php "redirect.php" care sa verifice daca pagina A e ok inainte sa faca redirect.

Exemplu:

1 useru' da click pe http://domain.com/Redirect.php?URL=http://site1.com/

2 redirect.php verifica daca websiteul (http://site1.com/) e ok!

3 daca e ok face redirect la http://site1.com/

4 daca websiteul http://site1.com/ nu e ok atunci verifica si face sau nu redirect la http://site2.com/

5 daca nici websiteul http://site2.com/ nu e ok, atunci verifica si face sau nu redirect la http://site3.com/

P.S. stiu ca se poate face asa ceva deoarece am avut un asemenea script dar nu il mai gasesc :(

  • Moderators
Posted (edited)


<?php
$link = $_GET['URL'];
$headere = get_headers($link);
if (stristr($headere[0], "200"))
header("Location: " . $link);
else
echo "Site-ul nu merge.";
?>

De aici te descurci :)

Edited by Dragos
Posted (edited)

sper sa reusesc sa il fac mai departe asa cum vreau eu, oricum mersi mult pentru ajutor.

doar ca am dat de o problema care ma depaseste....

Warning: get_headers() [function.get-headers]: This function may only be used against URLs

am pus si allow_url_fopen on .. si degeaba....

orice idee sau solutie e binevenita :)..

Edited by facnani
Posted
sper sa reusesc sa il fac mai departe asa cum vreau eu, oricum mersi mult pentru ajutor.

doar ca am dat de o problema care ma depaseste....

Warning: get_headers() [function.get-headers]: This function may only be used against URLs

am pus si allow_url_fopen on .. si degeaba....

orice idee sau solutie e binevenita :)..

pune @ in fata functiei get_headers, atat timp cat site-ul e ok va face redirect daca nu va da site-ul nu merge

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...