SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Location
    Auckland, NZ
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Site redirection if page not found

    Does anyone know some PHP code I could use to test if a website is down and if it is then redirect the current page to a designated page?

    Basically the following flow needs to happen:

    index.php is visited. As it opens up it check to see if site A is up. If so it proceeds to site A, if not it redirects to site B.

    The redirection part is not a problem, I'm just needing some ideas on testing for the invalid or not working site.

  2. #2
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,833
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    Try this:

    PHP Code:

       $file
    =''http://sitepoint.com';

       
    $str file_get_contents$file );

        echo 
    strlen($str); 
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Patche on earning Member of the Month for July 2014


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •