Jump to content

Redirect all be me


gilgimech

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/203232-redirect-all-be-me/
Share on other sites

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')

Link to comment
https://forums.phpfreaks.com/topic/203232-redirect-all-be-me/#findComment-1064808
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.