【发布时间】:2012-04-29 06:00:26
【问题描述】:
我的网站主页的所有代码都是“home.html”,但是我希望某人只需输入“example.com”即可转到“主页”页面,而不必输入在“example.com/home.html”中。我该怎么做?
【问题讨论】:
标签: html
我的网站主页的所有代码都是“home.html”,但是我希望某人只需输入“example.com”即可转到“主页”页面,而不必输入在“example.com/home.html”中。我该怎么做?
【问题讨论】:
标签: html
Web 服务器通常配置为在要求提供目录的根级别时提供具有特定名称的文件。一些例子是:
index.htmindex.htmlindex.xmlindex.rxmlindex.aspdefault.aspdefault.aspxindex.phpindex.cgiindex.shtmliisstart.htm如您所知,这可能因服务器和配置而异。
因此,要么重新配置您的网络服务器,将“home.html”视为有效主页,要么将其名称更改为您的服务器配置使用的任何名称。
在 Apache 中,这是使用 DirectoryIndex 指令配置的。
在 IIS 中,这些称为Default document。
【讨论】:
default.asp 和 default.aspx 用于 ASP.NET 下的 IIS
将你的主页命名为index.html,当用户访问example.com时,它将是你的网站自动跳转到的页面
【讨论】:
对于 Apache:
DirectoryIndex home.html index.html index.txt
对于 nginx:
location / {
try_files $uri $uri/ /home.html;
}
【讨论】: