2014-10-16 76 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