Apache – make inaccessible directory?

fmchanprogrammingLeave a Comment

You might encounter a case like your app hosting on domain.dev/middle/sub1 and you do not want anyone to access domain.dev/middle.

For http, you can add .htaccess to directory middle.

sudo nano /var/www/html/middle/.htaccess
<IfModule mod_rewrite.c>
  Options All -Indexes
</IfModule>

For https, you can add the following lines to default-ssl.conf

sudo nano /etc/apache2/sites-available/default-ssl.conf
<Directory /var/www/html/middle>
  Options All -Indexes
</Directory>
sudo service apache2 restart

Leave a Reply

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