Window 在 GoDaddy 上托管以重定向 index.html 到 root

Window hosting on GoDaddy to redirect index.html to root

如果我有一个 Windows 服务器,是否可以将我的 index.html 重定向到根目录:

www.example.com/index.html    -> www.example.com
http://example.com/index.html -> http://example.com 

我目前使用的主机不是 Apache,我使用的是 Windows 服务器。

又一次编辑:

元刷新标签

<meta http-equiv="refresh " content="0; url=www.example.com">

如果元刷新标签不起作用,我们可以尝试另外两个选项。

设置默认文档。 (更简单)

Web.Config 设置:

<system.webServer>
<defaultDocument enabled="true">
    <files>
        <clear />
        <add value="index.html" />
    </files>
</defaultDocument>
</system.webServer>

有关通过 web.config 进行设置的详细信息:Setting Default WebPage in IIS 7.5

或通过 IIS UI 设置(HOW TO 部分中的步骤 1 到 8):https://www.iis.net/configreference/system.webserver/defaultdocument

在 IIS 中创建重写规则。 (更难)

如果我们使用 Apache,我们将 create/update .htaccess 文件规则:

RewriteEngine On
RewriteRule ^index\.html$ / [R=301,L]
RewriteRule ^(.*)/index\.html$ // [R=301,L]

在 IIS 中,我们必须在 web.config 中以不同的方式添加这些重写规则。请参阅以下链接。

在 web.config 中创建重写规则的步骤:IIS URL Rewrite and Web.config

有关将 .htaccess 内容转换为 IIS 的详细信息 web.config:http://www.iis.net/learn/application-frameworks/install-and-configure-php-applications-on-iis/translate-htaccess-content-to-iis-webconfig

或在 IIS 中创建重写规则 UI:http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module