如何为网站制作主页?

时间:2012-04-29 06:00:26

标签: html

我的网站主页的所有代码都是“home.html”,但是我希望有人能够输入“example.com”并转到“主页”而不必输入在“example.com/home.html”中。我该怎么做?

3 个答案:

答案 0 :(得分:5)

Web服务器通常配置为在询问目录的根级别时为具有特定名称的文件提供服务。一些例子是:

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

如您所知,从服务器到服务器以及从配置到配置,这可能会有很大差异。

因此,要么重新配置您的网络服务器以对待" home.html"作为有效的主页,或将其名称更改为您的服务器配置使用的任何内容。

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

在IIS中,这些称为Default document

答案 1 :(得分:1)

为您的主页index.html命名,它将是您的网站在用户转到example.com时自动转到的页面

答案 2 :(得分:1)

对于Apache:

DirectoryIndex home.html index.html index.txt

对于nginx:

location / {
    try_files $uri $uri/ /home.html;
}
相关问题