Results 1 to 3 of 3

Thread: I need to redirect to a page if another page is not found

  1. #1
    Join Date
    Apr 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Post I need to redirect to a page if another page is not found

    Hello,

    I have a HTML page, which is hosted on the net
    and inside the html page there is an iframe which is hosted in my computer

    If someone tried to see this page while my computer is closed, a big white box that says "connection timed out" will appear (on firefox) and "Internet Explorer cannot display the webpage" (on IE) and so on... you know it better

    And the question is:
    Is there any way to use some kind of script so as to redirect that iframe to use another static page when the page on my computer is not available ?

    Thank you all in advance,
    Ted

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Can you use php or any other server side script on your server (the one on the net)? If so, you could use something like the following:

    Code:
    <?php
     error_reporting(0);
    
     if (fsockopen("www.yoursite.com", 80, $errno, $errstr, 30)) {
       header('Location: http://www.yoursite.com/computer.html');
     }
     else {
       header('Location: http://www.other-site.com/page.html');
     } 
    ?>
    Then, just have you iframe point to that php page. If you have any questions on the above code, just let me know.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. The Following User Says Thank You to thetestingsite For This Useful Post:

    ted (04-16-2008)

  4. #3
    Join Date
    Apr 2008
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thumbs up

    MANY THANKS !

    I encountered some problems at first, but when I moved my page to another server with a bit better php support, your script worked like charm!

    THANKS AGAIN !
    Last edited by ted; 04-16-2008 at 04:09 PM.

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
  •