如果我有一个Windows服务器,是否有可能将我的index.html重定向到root:
www.example.com/index.html -> www.example.com
http://example.com/index.html -> http://example.com 我目前使用的主机不是Apache,而是Windows服务器。
发布于 2016-05-23 00:34:54
还有另一个编辑:
元刷新标签
<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设置(“如何操作”部分中的步骤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 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
https://stackoverflow.com/questions/37381031
复制相似问题