+2 votes
in Web & Google by (71.8k points)
If I open my website by "www.mysite.com/data/", it shows all the folders and files present in the folder 'data'. What is the best way to prevent visitors from seeing website folders and file structure?

1 Answer

+1 vote
by (347k points)
selected by
 
Best answer

Option 1

If you have access to http.conf file, open this file and search for htdocs, then replace Options Indexes FollowSymLinks by Options FollowSymLinks. Basically, Indexes is responsible for showing your directory structure.

<Directory "/usr/local/apache/htdocs">

    Options FollowSymLinks

    AllowOverride None

    Require all granted

</Directory>

 Option 2

Open your .htaccess file and add the following line. It will give not 403 forbidden warning message

IndexIgnore *

Option 3

Open your .htaccess file and add the following lines. It will give 403 forbidden warning message and that's why you need to add a page for redirection if you want.

Options -Indexes

ErrorDocument 403 https://www.example.com


...