2012-04-29 48 views
0

我的網站主頁的所有代碼都是「home.html」,但我希望能夠讓某人只輸入「example.com」並轉到「主頁」頁面,而不必輸入「example.com/home.html」。我該怎麼做呢?如何爲網站製作主頁?

回答

5

Web服務器通常被配置成服務於文件具有特定名稱時,要求根級別的目錄。一些例子是:

  • index.htm
  • index.html
  • index.xml
  • index.rxml
  • index.asp
  • default.asp
  • default.aspx
  • index.php
  • index.cgi
  • index.shtml
  • iisstart.htm

當你明白了,這可以相差很大,從服務器到服務器,並從配置到配置。

因此,要麼重新配置您的Web服務器,將「home.html」視爲有效的主頁,要麼將其名稱更改爲您的服務器配置爲使用的任何名稱。

在Apache中,這是使用DirectoryIndex指令配置的。

在IIS中,這些被稱爲Default document

+1

此外:在ASP.NET – kaveman 2012-04-29 06:05:18

+0

...和「iisstart.html」下IIS的'default.asp'和'default.aspx' - 我將用更多示例更新我的答案。謝謝! – 2012-04-29 06:06:18

+0

謝謝,這工作! – 2012-04-29 06:16:06

1

名稱您的主頁的index.html,這將是該頁面你的網站會自動進入用戶時去example.com

+0

真棒,心動不如行動,現在排序。 – 2012-04-29 06:16:42

1

對於Apache:

DirectoryIndex home.html index.html index.txt 

對於nginx的:

location/{ 
    try_files $uri $uri/ /home.html; 
} 
+0

感謝您進一步澄清! – 2012-04-29 06:16:22