PDA

View Full Version : How to Set Website to be Accessible Only From Localhost for Development Purpose?


dealmaker
01-26-2006, 06:30 PM
Hi,
I am developing a website and I want to know how to make site and files only accessible from localhost. I am using apache, php, mysql and Fedora linux. I tried to set "Allowed from all" to "Allowed from localhost" in httpd.conf, but localhost can't access the website anymore.

Many thanks.

brett7481
01-26-2006, 06:57 PM
Havn't tried it, but something like this should work. Just put your code in the first php if statement:

<?php
// code

if ($_SERVER['HTTP_REFERER'] == "http://www.yourhost.com/" ) {
echo "
YOUR SITE CODE HERE\n";




} else {
echo "
NOT FOR PUBLIC DISPLAY\n";

}
?>


The above will only display the code if it is called from one of your other webpages. Otherwise if the referrer is from somewhere else, it won't display.

I think that will work. Just be sure to end your site with a .php extension.

dealmaker
01-26-2006, 07:22 PM
no, I don't want to remove the code in all those files before public release. I think there should be a way to do it in httpd.conf. I have Firestart firewall enabled, it should take care of the problem. But I want to be in the safe side, and set the rule in httpd as well.

Havn't tried it, but something like this should work. Just put your code in the first php if statement:

<?php
// code

if ($_SERVER['HTTP_REFERER'] == "http://www.yourhost.com/" ) {
echo "
YOUR SITE CODE HERE\n";




} else {
echo "
NOT FOR PUBLIC DISPLAY\n";

}
?>


The above will only display the code if it is called from one of your other webpages. Otherwise if the referrer is from somewhere else, it won't display.

I think that will work. Just be sure to end your site with a .php extension.