0

如果我有 Windows 服务器,是否有可能将我的 index.html 重定向到 root:

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

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

4

1 回答 1

1

另一个编辑:

元刷新标签

<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 设置的详细信息:在 IIS 7.5 中设置默认网页

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

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

如果我们使用 Apache,我们将创建/更新 .htaccess 文件规则:

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

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

在 web.config 中创建重写规则的步骤:IIS URL Rewrite 和 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

于 2016-05-23T00:34:54.700 回答