【发布时间】:2014-11-27 08:00:38
【问题描述】:
目前我正在使用另一家公司提供的网络托管服务。它使用IIS 7/IIS 8,允许客户根据需要修改web.config。
假设我设置了两个有效的 URL:
现在,当我尝试访问http://abc.example.com 时,返回HTTP Error 403.14 - Forbidden;如果我随后尝试访问http://www.example.com/abc,则返回HTTP Error 404.0 - Not Found。
如何配置web.config,以便用户在尝试访问无效网址时被重定向到http://www.example.com?
我尝试使用公司提供的sn-p但没有成功:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Canonical Host Name" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example\.com$" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
【问题讨论】:
-
看看这里,也许这可以帮助你进一步Convert isapi rewrite rules to IIS 7 rewrite
-
抱歉,在阅读了问题后,我仍然无法为我的案例设置正确的配置。
-
您的提供商是否支持 ISAPI?也许您可以尝试使用 ISAPI 规则将不存在的 url 重定向到您的主页:ISAPI DOCS
标签: asp.net iis url-rewriting dns