How to access only from localhost

Hi to everybody,

may be it’s a stupid question, but I’m not expert…

I developped an application using php (on Apache and Mysql). It is not an internet application, then my target is to use it only in the local PC where Apache is running.

Because the PC is connected to internet, how can I allow to run the my php pages ONLY from the locl PC (and then from localhost)? I want to avoid that somebody from the net can access to the my php pages.

I’ll really apprieciate if you can add the code to be inserted in order to do that…

Thank You very much in advance

Create a .htaccess file in your root directory and put these lines

order deny,allow
deny from all
allow from localhost


I’m not sure “localhost” would be recognized as a valid part of that command (for <Directory>).

Since I’m more of a mod_rewrite kinda guy, I’d say the same .htaccess should have:

RewriteCond &#37;{REMOTE_ADDR} !127\\.0\\.0\\.1$
RewriteRule .? - [F,L]

Since localhost’s IP Address IS, this says that anything other IP Address will get a Fail notification. Be sure to put that in the directory where you’re trying to protect your files and NOT where it’ll block additional traffic 'cause it will PREVENT outside access unconditionally.




I tried your solution but other persons on on the network can see browse my pages. But if I use my code with localhost or it works perfectly.