Apache Tutorial: Allow Directory While Restrict Certain Files

How to Restrict Specific Files in Apache?

In this tutorial i will show you how to enable a directory in Apache and yet restrict certain files browsing.

Enable Folder in Apache

To enable a folder in Apache you need to edit the HTTPD conf or create a new conf file like following:

vi /etc/httpd/conf.d/vhosts.conf

Enable the Directory

<Directory /sales>
AllowOverride none
Require all granted                                              # to allow all

Deny Specific File

Here I will be using the <files> Apache directive for this task.

<Files specificFILEname.txt>
Order Allow,Deny
Deny from all


The restart the Apache service:

Then restart the httpd service by running below command

service httpd restart

In RHEL 7.0

systemctle start httpd

Subscribe to
for video tutorials updates