Restrict directory access in Apache by allow some ip only

problem: Want to protect specific web directory in a simple way in the testing server

Solution: build conf file to restrict access in Apache. Go to /etc/apache2/sites-available/ , create your conf file in this website, for example, itdocumentation.com.conf. Then add below code:

<Directory /var/www/html/itdocumentation/>
Order allow,deny
Allow from 192.168.1.0/24
</Directory>

Then enable this Virtual Host configuration file:

a2ensite itdocumentation.com.conf

save it and restart apache

sudo service apache2 restart

You may also like...

1 Response

  1. March 18, 2019

    […] that user can not access through http://IP/project_name/public/ but to domain name. You can also Restrict directory access in Apache by allow some ip only in order to protect .env file and other sensitive […]

Leave a Reply

Your email address will not be published. Required fields are marked *