views:

130

answers:

2

I want to allow access to a file (secret.txt) only from my ip. Below is the .htaccess I'm using. It works great at my provider's server. However, at my localhost this .htaccess does not allow me to access the file.

<Files "secret.txt">
    order deny,allow
    deny from all
    allow from 1.2.3.4
</Files>

Where my external ip is "1.2.3.4"

I use Apache server locally.

How can I make things work at localhost also?

+3  A: 

What Address are you using to access your local Apache server? If you're addressing it as localhost then you're probably not going all the way out of your machine via the network and back in again. This means that as far as your local Apache server is seeing you, you're coming from a loopback address.

Try putting 127.0.0.1 in instead of your external IP, and see if that works.

GAThrawn
Thank you for the instant response!Yeah, I'm using localhost.Now I see where is the problem.I've added "allow from 127.0.0.1" and it works now.Thank you!!!
Pavel
A: 

Try looking into your local server's access logs: does your local server see 1.2.3.4 when you are accessing the file from the computer that should be allowed? You may see a different IP address (due to NATs and whatnot).

Piskvor