IIS7 URL重写到不同的域,完全匹配

Jam*_*Hay 10 iis iis-7 url-rewriting

我基本上想要匹配确切的地址

http://www.example.com/mysite

并将其重定向到

http://www.example2.com/something/something

如果可能,我希望能够使用IIS,因为我已经为example.com编写了一个内部重写模块,将用户友好的URL重写为aspx页面,我不希望任何干扰其他站点.

NINJA编辑:

我想将地址保留为http://www.example.com/mysite,所以我需要重写它而不是重定向它.

Mar*_*urg 20

这应该做的工作:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Redirect mysite" stopProcessing="true">
                    <match url="^mysite$" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^www\.example\.com$" />
                    </conditions>
                    <action type="Redirect" url="http://www.example2.com/something/something" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

  • 在这种情况下,您需要通过在 IIS 中安装 [ARR 模块](http://www.iis.net/download/ApplicationRequestRouting) 来设置反向代理。不确定这是否是解决这种情况的好方法,尤其是当 example2.com 托管在其他地方时。 (2认同)
  • 由于我有同样的问题并认为有人可能会来这里,这是您实际问题的解决方案:http://www.iis.net/learn/extensions/url-rewrite-module/reverse-proxy-with-url-rewrite -v2-and-application-request-routing (2认同)