i want to make wamp homepage to be accessed from a list of allowed ip, and the one that are not in the list to be redirected into a webfile. like this..
example.com
allowed ips: 127.0.0.1 192.168.1.174 192.168.1.123 200.256.65.1
thoses that are not in the list are going to be redirected to example.com/test (if possible, to be redirected into that directory but just showing in the explorer example.com).
ive been told to use the htaccess 'RewriteMap' but i dont know how that really works, please someone help
Updated: When its accessed from a dns, could it get its ip from where is requested?
Using PHP : First of all get the current domain using $_SERVER['HTTP_HOST']
and then identify it's authenticated or not ! Simple. Here's Lil Code Snippet !
1) Create a PHP array to store all the allowed domain :
$domains = array(
"127.0.0.1",
"192.168.1.174",
"192.168.1.123",
"200.256.65.1"
);
2) Create another file domain_check.php and add following code :
<?php
$current_domain = $_SERVER['HTTP_HOST'];
if(!in_array($current_domain,$domains)) {
header("Location: http://google.com");
}
?>
include above file at the top of you pages. It's done :)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments