Using htaccess, how to restrict seeing directory contents, but allow server to use the contents?

后端 未结 11 1808
既然无缘
既然无缘 2021-01-30 22:38

More specifically, I have an htaccess file that restricts anyone from seeing the directory contents. Such that, nobody can see my 1000s of images in www.example.com/images by us

11条回答
  •  生来不讨喜
    2021-01-30 23:23

    All you need to keep people from seeing the directory contents is an index.php or .html file in that folder. Any requests for yoursite.com/images will load index.php, which you'll set to a dummy page.

    index.html could be something like:

    Forbidden!Nothing to see here...
    

    or a redirect script index.php:

    
    

    Don't use .htaccess for blocking directory listings, it blocks access to everything.

提交回复
热议问题