Iis 如何将每个到sub.sub.domain.com的请求重定向到sub.domain.com?(Azure云服务)

Iis 如何将每个到sub.sub.domain.com的请求重定向到sub.domain.com?(Azure云服务),iis,azure,Iis,Azure,我正在尝试将我的web.config配置为将所有请求重定向到。我的项目托管在WindowsAzure的云服务中 以下是我尝试过的(但不起作用) 有人能帮忙吗 多谢各位 尝试更新web.config以包含以下内容: <rule name="My redirection"> <match url="(.*)" /> <conditions> <add input="{HTTP_HOST}" pattern="^sub.su

我正在尝试将我的web.config配置为将所有请求重定向到。我的项目托管在WindowsAzure的云服务中

以下是我尝试过的(但不起作用)


有人能帮忙吗


多谢各位

尝试更新web.config以包含以下内容:

<rule name="My redirection">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^sub.sub.domain.com$" />
    </conditions>
    <action type="Redirect" url="http://sub.domain.com/{R:1}" redirectType="Permanent" />
</rule>

好的,我终于在global.asax中的BeginRequest事件中使用了解决方案来处理这个问题。以下是我使用的代码:

protected void Application_BeginRequest( object sender, EventArgs e )
{
  if( this.Request.Url.Host.StartsWith( "sub.sub.domain.com" ) )
  {
    var uriBuilder = new UriBuilder( this.Request.Url );
    uriBuilder.Host = this.Request.Url.Host.Replace( "sub.sub.domain.com", "sub.cuisinaviva.com" );

    this.Response.RedirectPermanent( uriBuilder.ToString() );
  }
}
为了添加更多关于我的项目的信息,它是一个托管在ASP.NET MVC 4项目中的Silverlight 5应用程序


注意:我认为Andy给出的解决方案可能很好,因为我在其他地方看到了一些类似的Awner。我只是不确定这是否适用于Azure…

谢谢Andy,但它似乎不适用于我。我不知道这是否是因为Azure,但重定向不起作用:(嗨,Jacques,sub.sub.domain.com是否绑定到您的Azure部署?如果您的意思是该域在Azure内配置,则否。在我的DNS服务器中,我为sub.sub.domain.com添加了一个CNAME记录,指向mydomain.cloudapp.net。我还为sub.domain.com添加了一个CNAME记录,指向相同的cloudapp.net地址。以确保此操作正常。)预计我刚刚为一个新的Azure Web角色部署了一个测试解决方案,建议的规则运行良好。明天我将不得不做更多的测试。谢谢你的输入Andy。我会随时通知你。
protected void Application_BeginRequest( object sender, EventArgs e )
{
  if( this.Request.Url.Host.StartsWith( "sub.sub.domain.com" ) )
  {
    var uriBuilder = new UriBuilder( this.Request.Url );
    uriBuilder.Host = this.Request.Url.Host.Replace( "sub.sub.domain.com", "sub.cuisinaviva.com" );

    this.Response.RedirectPermanent( uriBuilder.ToString() );
  }
}