简体   繁体   English

在某些目录中没有index.html文件的缺点是什么

[英]What are the downside of not having an index.html file to some directories

I'm curious what are some effects/downside of not putting an index.html file to your directories (eg images). 我很好奇没有将index.html文件放到目录(例如图像)有什么影响/缺点。 I know when an index file is not present to a directory, files inside that directory are no longer private and will be visible to the browsers when point (eg yoursite.com/images/). 我知道当目录中没有索引文件时,该目录中的文件将不再是私有的,并且在指向时将对浏览器可见(例如yoursite.com/images/)。 Aside from that what are some big effects to consider? 除此之外,还有什么需要考虑的重大影响? and how to properly secure them. 以及如何正确保护它们。

thanks! 谢谢!

This depends on your web server, but there are two disadvantages to not having one. 这取决于您的Web服务器,但是没有一个有两个缺点。

  1. If not secured, some web servers will show the directory contents if there is no default page. 如果不安全,那么如果没有默认页面,某些Web服务器将显示目录内容。
  2. If someone types your_site/directory/, and there is no default page, they will receive a 404 error. 如果有人键入your_site / directory /,并且没有默认页面,则他们将收到404错误。

With current web servers, there are many ways to get around not having a default page for each directory. 对于当前的Web服务器,有很多方法可以避免每个目录没有默认页面。 You can set the custom 404 to redirect to a page that is available, and some can put one in automatically for you. 您可以将自定义404设置为重定向到可用的页面,有些页面可以自动为您放置一个页面。 As far as security goes, you can just turn off directory browsing to not allow people to see the contents. 就安全性而言,您可以关闭目录浏览以使人们无法查看其内容。

If you are configuring your own server, not having one becomes less of an issue since you can control how the server responds to such situations. 如果您要配置自己的服务器,那么没有服务器成为一个问题,因为您可以控制服务器对这种情况的响应方式。 People normally just put it in as a fail safe, to make sure that the above two problems are taken care of. 人们通常只是将其作为故障安全装置,以确保解决以上两个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM