我有一个纯HTML网站克隆到我的本地XAMPP服务器,它是在'foo‘文件夹下。在此文件夹中,只有.html文件和空.htaccess文件。当我打开URL localhost/foo时,浏览器将打开localhost/foo/index.html文件。那么问题是,服务器如何知道它是打开index.html文件的呢?
发布于 2014-10-16 19:56:45
如果您检查XAMPP安装(C:\xampp\apache\conf\httpd.conf)的apache文件,您将在DirectoryIndex下找到以下声明
<IfModule dir_module>
DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>最后,index.html将是apache试图加载的第6个文件。您可以自定义此列表,在XAMPP控制面板中重新启动apache,并加载不同的默认文件。
发布于 2014-10-16 19:56:50
这是由Apache配置DirectoryIndex确定的。示例:
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
# The index.html.var file (a type-map) is used to deliver content-
# negotiated documents. The MultiViews Option can be used for the
# same purpose, but it is much slower.
#
DirectoryIndex index.php index.html index.html.var发布于 2014-10-16 20:03:25
当没有显式请求其他页面时,服务器将打开index.html (或index.htm或index.php),因为这是网站上每个目录的默认页面。如果您请求zyx.com\reports.html,那么您将打开reports.html页面,因为您指定了要查看的页面。当您不要求一个特定的页面(即在地址栏中输入zyx.com )时,该目录的默认页面就是索引页,因此打开的就是索引页。如果键入zyx.com而没有为该目录创建索引页,会发生什么情况?服务器将返回该目录中所有文件的列表,显示指向所有文档和/或图像的链接。还有一个指向父目录的链接,因此在实践中,查看器可以访问您的文件来查找感兴趣的内容。
https://stackoverflow.com/questions/26412692
复制相似问题