Results 1 to 3 of 3

Thread: If Install.php Exists, redirect to install.php

  1. #1
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default If Install.php Exists, redirect to install.php

    Hi there,

    My script has an install.php file which if it exists, I want it to redirect to the install.php file. I entered this code in index.php:
    Code:
    //----------------------------
    // Checking If Install File Exists!
    //----------------------------
    if(is_dir('./install.php') and $_SERVER['HTTP_HOST'] != 'localhost')
    {
    	header("Location: ./install.php");
    	die();
    }
    //----------------------------
    // Finished Checking
    //----------------------------
    But it didn't work, it just views index.php naturally, even if install.php exists, what I'm I doing wrong?

    Many thanks for your help.

    Best Regards,
    Private_Guy

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

    Default

    Try this instead:

    Code:
    //----------------------------
    // Checking If Install File Exists!
    //----------------------------
    if(file_exists('./install.php') and $_SERVER['HTTP_HOST'] != 'localhost')
    {
    	header("Location: ./install.php");
    	die();
    }
    //----------------------------
    // Finished Checking
    //----------------------------
    The reason it was not working is because install.php is not a dir and that's what you were checking for.
    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. #3
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Solved!

    Hi there,

    I just want to personally thank you, you solved it for me, it works like a charm. Cheers m8.

    Best Regards,
    Chill_Guy

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
  •