user1432059
user1432059

Reputation:

Disallow view of specific file on Apache

In my site I've some file used by my application where are putted the log information. For example a log file is "access.log", and i write in by PHP. If a visitor go to www.mysite.ext/access.log , can see the file and all the information inside it. How can I disallow this? thanks a lot

Upvotes: 0

Views: 1016

Answers (2)

cwill747
cwill747

Reputation: 536

If you want to do this in Apache, you can add the following to your .htaccess:

<files access.log>
deny from all
</files>

Upvotes: 3

Knyri
Knyri

Reputation: 3028

Put this in your .htaccess

<FilesMatch "\.(htaccess|htpasswd|pinc|ini|phps|fla|psd|log|sh)$">
 Order Allow,Deny
 Deny from all
</FilesMatch>

Will block .log and other common files you don't want people to access.

Upvotes: 4

Related Questions