Helpful Information
 
 
Category: Post a PHP snippet
Substitution for .htaccess password

dns.inc.php:

<?php
if (!stristr( $_SERVER['HTTP_HOST'], 'server2')) {
header('Location: http://games.game-host.org/css');
}
?>
where server2 is the computers name and http://games.game-host.org/css is the address to go to if the domain is not correct.
------------------------------------
This will only work if the client and the server are on the same network.

Purpose:
I did this because I needed a way to have an admin panel just for me. This also takes all passwords out of it. No passwords and no usernames.

How?
server2 has to be a network only dns(computer name). Then have it redirect to anything you want if its not correct.
Just include that dns.inc.php page on every page ytou want protected.

Working example:
http://games.game-host.org/css/maps_admin/
will redirect you to:
http://games.game-host.org/css/
But
http://server2/css/maps_admin/
will be the page with no change. You will not even know it is there.
http://server2/css/maps_admin

I am afraid it might fail.

weird... its worked great so far

you cannot trust any $_SERVER variable that begins with HTTP (e.g., $_SERVER["HTTP_REFERER"], $_SERVER['HTTP_HOST'])

See for example http://shiflett.org/archive/98

OK, well I wont use that anymore.
I am more or less a php newbie... BUt im getting better.



ILLINI










privacy (GDPR)