porton
porton

Reputation: 5803

How to deny access to a file using .htaccess?

I need to block access to a particular file (containing private data) in a directory using .htaccess. Is this possible?

We use Apache and nginx.

Upvotes: 0

Views: 333

Answers (2)

b3h3m0th
b3h3m0th

Reputation: 1366

if you want to prevent viewing of a specific file, for example picture.jpg:

<files picture.jpg>
     order allow,deny
     deny from all
</files>

change picture.jpg with your file.

If you want to deny access to all files with .jpg extension:

<files  ~ "\.jpg$">
  Order allow,deny
  Deny from all
</files>

Upvotes: 1

Kamil Šrot
Kamil Šrot

Reputation: 2221

<Files "yourfile">
  Order allow,deny
  Deny from all
  Satisfy all
</Files>

See apache docs for more info...

Upvotes: 0

Related Questions