Uffo
Uffo

Reputation: 10056

How can I protect a directory using .htaccess?

How can I protect a folder using .htaccess? I want the folder /files/myfiles to only be accessed by the server, not by a user? How can I do that?

Upvotes: 0

Views: 329

Answers (3)

Uffo
Uffo

Reputation: 10056

I found this thing: Options -Indexes is hiding directory listing

Upvotes: 0

Al.
Al.

Reputation: 2882

I would add the following to an .htaccess:

order deny,allow
deny from all
allow from localhost
allow from 127.0.0.1 // incase your loopback isn't configured correctly
allow from 192.168 // incase software isn't using your loopback correctly

Hope that helps!

Upvotes: 2

Garrett
Garrett

Reputation: 8090

Add the .htaccess file to /files/myfiles folder with the following in it:

deny from all

Internally when your scripts look for files they aren't going through Apache, only when someone requests it on port 80. So this will deny any listing and permissions to them.

Upvotes: 3

Related Questions