2014-10-16 77 views
0

我有一个纯HTML网站克隆到我的本地XAMPP服务器,它位于'foo'文件夹下。在这个文件夹中,只有.html文件和一个空的.htaccess文件。 当我打开URL localhost/foo时,浏览器将打开localhost/foo/index.html文件。所以问题是,服务器如何知道打开index.html文件?网络服务器如何识别登录页面?

回答

1

如果选中了Apache的conf文件为您的XAMPP安装(C:\ XAMPP的\ apache的\的conf \ httpd.conf文件),你会发现下,以下声明的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,并具有不同的默认文件加载。

0

这由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 
0

服务器将打开index.html(或index.htm或index.php文件)时,明确要求没有其他的页面,因为这是在网站上的每个目录的默认页面。如果您要求提供zyx.com \ reports.html,那么您将打开reports.html页面,因为您指定了要查看的页面。如果您没有要求提供特定页面(即您在地址栏中输入zyx.com),那么该目录的默认页面就是索引页面,所以这就是打开的页面。如果您键入zyx.com并且没有为该目录创建索引页会发生什么情况?服务器将返回该目录中所有文件的列表,显示所有文档和/或图像的链接。还会有一个指向父目录的链接,因此在实践中,查看者将能够访问您的文件以查找感兴趣的内容。

0
Mostly servers support index.html as default file. But if you have any other file which  you want to make it as landing page. You may change you htaccess 

DirectoryIndex filename.extension 

You can add multiple files there like following example. In this case anyone of theme present will be landing page. If all present then first will be given priority. 

DirectoryIndex filename.extension filename.extension filename.extension