【问题标题】:How to make home page for website?如何制作网站首页?
【发布时间】:2012-04-29 06:00:26
【问题描述】:

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

【问题讨论】:

    标签: html


    【解决方案1】:

    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

    【讨论】:

    • 另外:default.aspdefault.aspx 用于 ASP.NET 下的 IIS
    • ...和“iisstart.html” - 我将用更多示例更新我的答案。谢谢!
    【解决方案2】:

    将你的主页命名为index.html,当用户访问example.com时,它将是你的网站自动跳转到的页面

    【讨论】:

    • 太棒了,现在都整理好了。
    【解决方案3】:

    对于 Apache:

    DirectoryIndex home.html index.html index.txt
    

    对于 nginx:

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

    【讨论】:

    • 感谢您进一步澄清!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-23
    • 2016-10-28
    • 1970-01-01
    相关资源
    最近更新 更多