IIS重定向到完整域名

时间:2015-10-01 16:55:41

标签: iis iis-7

我需要从

重定向

http://someserver/someapplication.page.aspxhttp://someserver.domain.com/someapplication.page.aspx

这两个请求都指向同一台服务器。

someserver/通过我们公司的内部DNS工作

这是与Redirecting to Full Domain

相同的问题

但我想要一个IIS解决方案,而不是代码。我的猜测是,它会与使用通配符在配置编辑器中添加httpRedirect添加元素有关。

1 个答案:

答案 0 :(得分:1)

您可以使用URL Rewrite作为在IIS中执行此操作的方法,只需使用以下规则添加web.config:

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Redirect to full domain" stopProcessing="true">
          <match url=".*" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^someserver$" />
          </conditions>
          <action type="Redirect" url="http://someserver.domain.com/{R:0}" redirectType="Permanent" />
        </rule>
      </rules>

    </rewrite>
  </system.webServer>
</configuration>