Blocking all ips except localhost

Hi…

I am using xammp in my local and trying plan to block a folder.

Say my machines IP is 45.45.45.45 and I am accessing the folder names “bob” from another machine (LAN) via http.

so http://45.45.45.45/bob works just fine.

Now, if I want to block this folder from accessing another machine (LAN), but still need to access to that dir from my local via http (http://localhost/bob), what should my .htaccess file look like.

I tried following, but it blocks me accessing this folder from my local machine as well.

order deny,allow
deny from all
allow from localhost

szms,

First, WELCOME to SitePoint’s Apache forum!

I’d first recommend that you configure your firewall to prohibit access EXCEPT to those IP Addresses you want to allow. That should be the easiest (and most effective) solution.

If you have mod_rewrite installed, it should be an easy matter to have it examine (via RewriteCond) the {REMOTE_ADDR} in a similar manner to what the firewall should be doing.

Regards,

DK

dklynn,

Your first option is not feasible to my issue as I need to restrict all external ips in order to access to a specific folder. [unless the is a way to do it :)] Rest of the folders can be accessed vis http by external ips. So I added a exception for port 80 on firewall in my local machine.

I will look into your 2nd options.

In the mean time, I tried following -

I just put following on .htaccess file inside the folder that I wanted to restrict.

<Limit GET PUT POST>
order deny,allow
deny from all
allow from 127.0.0.1
</Limit>

After restarting Apache, I am getting following error. I also get similar error if use the IP of my local instead of 127.0.0.1

Server error!

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.

If you think this is a server error, please contact the webmaster.
Error 500
127.0.0.1
12/26/2010 11:53:29 AM
Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1

sz,

Hmmm, I can’t say that I’d ever seen GET, PUT and POST like that before so I’d guess that the POST is incorrect. Please TRY getting rid of the POST in the <Limit … > line.

Regards,

DK