-1

Actually i have a website www.domain.com

when i tried to inspect element and try to access www.domain.com/css/ then it showed all the files in the directory

Structure

  • /css/
  • /images/
  • /include/
  • /js/
  • index.html
  • contact.html
  • sitemap.xml
  • style.css
  • robot.txt
  • .htaccess

i want css,images,include,js folder to be protected means if anyone try to access www.domain.com/images/ then he should be redirected to www.domain.com/index.html rest index.html,contact.html,sitemap,robot.txt should be publicly accessible and www.domain.com/images/abcd.jpg can be publicly accessible but www.domain.com/images/ should not be publicly accessible.

can anyone tell me how to do that?

1 Answers1

0

You can disable directory listing with this option in your server config or in .htaccess:

Options -Indexes

Details here: https://wiki.apache.org/httpd/DirectoryListings

To redirect the user to your homepage, use a rewrite rule or put a redirect in your HTTP 403/404 error page.

Hubert Grzeskowiak
  • 15,137
  • 5
  • 57
  • 74