首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在GoDaddy上托管窗口,将index.html重定向到root

在GoDaddy上托管窗口,将index.html重定向到root
EN

Stack Overflow用户
提问于 2016-05-23 00:24:09
回答 1查看 877关注 0票数 0

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

代码语言:javascript
复制
www.example.com/index.html    -> www.example.com
http://example.com/index.html -> http://example.com 

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-05-23 00:34:54

还有另一个编辑:

元刷新标签

代码语言:javascript
复制
<meta http-equiv="refresh " content="0; url=www.example.com">

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

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

Web.Config设置:

代码语言:javascript
复制
<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设置(“如何操作”部分中的步骤1至步骤8):https://www.iis.net/configreference/system.webserver/defaultdocument

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

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

代码语言:javascript
复制
RewriteEngine On
RewriteRule ^index\.html$ / [R=301,L]
RewriteRule ^(.*)/index\.html$ /$1/ [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中创建重写规则:http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37381031

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档