note 90656 modified in reserved.variables.server by danbrown

From: Date: Sun, 03 May 2009 17:00:19 +0000
Subject: note 90656 modified in reserved.variables.server by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154161@lists.php.net to get a copy of this message
Here's a simple, quick but effective way to block unwanted external visitors to your local server: <?php // only local requests if ($_SERVER['REMOTE_ADDR'] !== '127.0.0.1') die(header("Location: /")); ?> This will direct all external traffic to your home page. Of course you could send a 404 or other custom error. Best practice is not to stay on the page with a custom error message as you acknowledge that the page does exist. That's why I redirect unwanted calls to (for example) phpmyadmin. --was-- Here's a simple, quick but effective way to block unwanted external visitors to your local server: // only local requests if ($_SERVER['REMOTE_ADDR'] !== '127.0.0.1') die(header("Location: /")); This will direct all external traffic to your home page. Of course you could send a 404 or other custom error. Best practice is not to stay on the page with a custom error message as you acknowledge that the page does exist. That's why I redirect unwanted calls to (for example) phpmyadmin. http://php.net/manual/en/reserved.variables.server.php

« previous php.notes (#154161) next »