Skip to content

Instantly share code, notes, and snippets.

@BHWD
Created May 17, 2017 11:31
Show Gist options
  • Save BHWD/c8c44f2820359f842d6053128160c37d to your computer and use it in GitHub Desktop.
Save BHWD/c8c44f2820359f842d6053128160c37d to your computer and use it in GitHub Desktop.
Redirect users based on IP. USeful for hiding websites from clients
<?php
$visitor = $_SERVER['REMOTE_ADDR'];
if (preg_match("/192.168.0.1/",$visitor)) {
header('Location: http://www.yoursite.com/thank-you.html');
} else {
header('Location: http://www.yoursite.com/home-page.html');
};
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment