目前,我已经设置了IIS8来使用静态网站来回答www.IPO.is。然后,我让asp.net项目响应www.IPO.is的特定子目录(例如,www.IPO.is/test)。

现在,我将静态网站转移到不同的位置和URL,所以我希望旧的URL重定向到新的项目。(ipo.keldan.is)
有没有办法让IIS回答www.ipo.is的重定向,但仍然像以前一样服务于www.ipo.is/test?
发布于 2018-06-12 16:58:00
在莫辛·马哈茂德给出了一个很好的提示后,我设法找到了解决这个问题的方法。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="IPO Redirect" stopProcessing="true">
<match url="(.+)" negate="true" />
<action type="Redirect" url="http://ipo.keldan.is" redirectType="Permanent" />
<conditions>
<add input="{HTTP_HOST}" pattern="(.*)ipo.is" />
</conditions>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>这与没有主机ipo.is子目录的任何URL匹配(带有http/https和www/non的任何变体)。
发布于 2018-06-12 15:51:43
您可以使用IIS UrlRewrite扩展。在静态网站目录的根目录创建一个web.config文件,然后粘贴到以下内容中:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect rule" patternSyntax="ECMAScript" stopProcessing="true">
<match url="/$" />
<action type="Redirect" url="http://ipo.keldan.is" />
<conditions>
<add input="{HTTP_HOST}" pattern="^ipo.is$" />
</conditions>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>确保在应用此更新之前安装了UrlRewrite扩展。可以使用Microsoft UrlRewrite安装程序安装WebPlatform。
https://stackoverflow.com/questions/50819940
复制相似问题