Log in

View Full Version : If Install.php Exists, redirect to install.php



Private_Guy
08-19-2007, 05:54 PM
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:


//----------------------------
// 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

thetestingsite
08-19-2007, 06:15 PM
Try this instead:



//----------------------------
// 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.

Private_Guy
08-19-2007, 06:31 PM
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