mardi 3 février 2015

PHP Code No Longer Works When Moved to Another Server

I have my test server on KnownHost (Apache), and my live server on Amazon web services (nGinx).


Here is the code that works perfectly fine on my KnownHost server:



$file1 = file("file1.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$file2 = in_array($_SERVER['REMOTE_ADDR'], $file1);

$file3 = file("file4.txt", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$file4 = in_array($_SERVER['REMOTE_ADDR'], $file3);

if ( $file2 ) {
header("Location: page3.php?". $_SERVER['QUERY_STRING']);

} elseif ( $file4 ) {
if ($_SERVER['HTTP_HOST']=="domain1.com") {
header("Location: http://google.com");
} elseif ($_SERVER['HTTP_HOST']=="domain2.com") {
header("Location: http://cnn.com");
} else {
header("Location: http://cbs.com");
}

} else {
echo "test";
exit;
}


What this small bit of code will do is look for IPs in a file. If the IP is found in file1.txt it will redirect to page3.php, if the IP is found in file4.txt it will redirect to a website based on if the current domain is domain1.com or domain2.com, and if there is no IP found in any file it will echo test


On my test server this works just as described above, on my live server it will always echo "test" even when my IP is in the file for testing purposes.


I'm not getting any errors even with error_reporting(E_ALL); at the top of my file, is there anything else I can test?


Aucun commentaire:

Enregistrer un commentaire