Deny Remote Access (Only allow Localhost)

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
Verminox
Forum Contributor
Posts: 101
Joined: Sun May 07, 2006 5:19 am

Deny Remote Access (Only allow Localhost)

Post by Verminox »

Am I right in saying that if I have the following at the top of my script then that particular page cannot be accessed remotely?

Code: Select all

<?php
if( $_SERVER['HTTP_HOST'] != 'localhost' || $_SERVER['SERVER_NAME'] != 'localhost' )
{
    die("Remote access denied");
}
?>
I'm developing an app for a client who will be using it only on his own PC, and it's not meant for anybody else to access. Although there isn't going to be any highly sensitive information (the app is password protected anyway), I'd just prefer that nobody having the IP address can snoop around.
Post Reply