Last active
December 22, 2015 06:58
-
-
Save gabrielef/6434583 to your computer and use it in GitHub Desktop.
Thi script redirect not unauthorized users, for example during maintenance.Put ip address of authorized users inside the $admin array.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//admins address | |
$admins = array('97.23.95.1', '192.168.1.74'); | |
//redirect page for unauthorized users | |
$page = 'http://www.sitename.com/redirectpage.html'; | |
////////////////////////////////////////////////////////////////////////// | |
//user ip address | |
$user = $_SERVER['REMOTE_ADDR']; | |
//user will be redirect to $page if its ip isn't in the $admin array | |
//var_dump(array_search($user, $admin)); | |
if(array_search($user, $admins) === FALSE) | |
{ | |
header('Location: ' . $page); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment