Skip to content
Advertisement

How to stop directory listing for angular project in Linux

I have deployed angular 8 project in linux sub domain (web.mydomain.com), but when I am accessing web.mydomain.com directory listing is showing instead of loading website, but when I am accessing http://web.mydomain.com/index.html it is working.

Below is the htaccess file looks like :

RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]

# If the requested resource doesn't exist, use index.html
RewriteRule ^(.*)$ index.html

Advertisement

Answer

Add following line in your htaccess

Options -Indexes

Either you may try

<VirtualHost *:80>  
    DocumentRoot /home/user/www
    ServerName myserver.local

    <Directory /home/user/www/>
        Options FollowSymLinks MultiViews   
    </Directory>

    <Directory /home/user/www/appdir3>
        Options Indexes
    </Directory>
</VirtualHost>
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement