gilgimech Posted May 28, 2010 Share Posted May 28, 2010 I'm using this script to redirect for site maintenance. <?php $hostname="localhost"; $username="xxxxxx"; $password="xxxxxx"; $database="xxxxxx"; $tbl_name="xxxxxx"; // Connect to the database MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect"); MYSQL_SELECT_DB("$database") OR DIE("Unable to select database"); $result = mysql_query("SELECT * FROM $tbl_name") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { $maint_on_off = $row['on_off']; } if ($maint_on_off == "1") { header ('Location: ../maintenance.php'); } ?> Does anyone know how I can redirect everyone except myself. Maybe using IP to detect. Quote Link to comment https://forums.phpfreaks.com/topic/203232-redirect-all-be-me/ Share on other sites More sharing options...
jdavidbakr Posted May 28, 2010 Share Posted May 28, 2010 Test $_SERVER['HTTP_REMOTE_ADDR'] Quote Link to comment https://forums.phpfreaks.com/topic/203232-redirect-all-be-me/#findComment-1064798 Share on other sites More sharing options...
Philip Posted May 28, 2010 Share Posted May 28, 2010 If your running of Apache, why not just use .htaccess to do this for you? Quote Link to comment https://forums.phpfreaks.com/topic/203232-redirect-all-be-me/#findComment-1064802 Share on other sites More sharing options...
gilgimech Posted May 28, 2010 Author Share Posted May 28, 2010 Test $_SERVER['HTTP_REMOTE_ADDR'] Not what I was looking for. I need something like <?php if ('My IP Adress") { do not redirect } else (Any other IP){ redirect }; ?> I just don't know how to implement that into my current code Quote Link to comment https://forums.phpfreaks.com/topic/203232-redirect-all-be-me/#findComment-1064803 Share on other sites More sharing options...
gilgimech Posted May 28, 2010 Author Share Posted May 28, 2010 If your running of Apache, why not just use .htaccess to do this for you? I'm having issues with htaccess displaying images. It works, I just can't get the images to load. Quote Link to comment https://forums.phpfreaks.com/topic/203232-redirect-all-be-me/#findComment-1064805 Share on other sites More sharing options...
Philip Posted May 28, 2010 Share Posted May 28, 2010 If your running of Apache, why not just use .htaccess to do this for you? I'm having issues with htaccess displaying images. It works, I just can't get the images to load. What do you mean? Quote Link to comment https://forums.phpfreaks.com/topic/203232-redirect-all-be-me/#findComment-1064807 Share on other sites More sharing options...
jdavidbakr Posted May 28, 2010 Share Posted May 28, 2010 Test $_SERVER['HTTP_REMOTE_ADDR'] Not what I was looking for. I need something like <?php if ('My IP Adress") { do not redirect } else (Any other IP){ redirect }; ?> I just don't know how to implement that into my current code Um ... I think it is if ($_SERVER['REMOTE_ADDR'] == '123.456.789') { do not redirect } else { redirect }; (I actually typed the variable wrong the first time, it should be just 'REMOTE_ADDR') Quote Link to comment https://forums.phpfreaks.com/topic/203232-redirect-all-be-me/#findComment-1064808 Share on other sites More sharing options...
gilgimech Posted May 28, 2010 Author Share Posted May 28, 2010 Sweat seems to work. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/203232-redirect-all-be-me/#findComment-1064822 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.