HTTP重定向为Windows Azure最佳实践 [英] Best practice for http redirection for Windows Azure

查看:384
本文介绍了HTTP重定向为Windows Azure最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个蔚蓝的网站,该网站被命名为:

I have an azure website which is named:


  • http://myapp.cloudapp.net

  • http://myapp.cloudapp.net

中,当然这个URL是一种丑恶的,所以我成立一个CNAME 这点 http://www.myapp.com 来蔚蓝的URL。

Of-course this URL is kind of ugly so I set up a CNAME that points http://www.myapp.com to the azure url.

一切都很好,直到这里,但有一个障碍。

All is well up until here, but there is a snag.

http://myapp.cloudapp.net 泄露出去了,现在是由谷歌索引和住在其他网站。

http://myapp.cloudapp.net has leaked out and now is indexed by google and lives on other sites.

我想在www.myapp.com

I would like to permanently redirect any requests for myapp.cloudapp.net to the new home at www.myapp.com

该网站我是MVC.Net 2.0 codeD,因为这是一个天蓝色的应用程序,没有用户界面来访问IIS和一切都需要在应用code或web.config中完成。

The website I have is coded in MVC.Net 2.0, as this is an azure app, there is not UI to access IIS and everything needs to be done in application code or web.config.

什么是清洁的方式来设置永久重定向的地方,它应该走在web.config中或在全局控制器?

What is a clean way to set a permanent redirect in place, should it go in web.config or in a global controller?

推荐答案

您可能要改用IIS重写模块(似乎干净)。这里有一个博客帖子显示如何做到这一点:<一href=\"http://weblogs.asp.net/owscott/archive/2009/11/30/iis-url-rewrite-redirect-multiple-domain-names-to-one.aspx\">http://weblogs.asp.net/owscott/archive/2009/11/30/iis-url-rewrite-redirect-multiple-domain-names-to-one.aspx. (您只需把相关的标记在web.config中。)

You might want to instead use the IIS rewrite module (seems "cleaner"). Here's a blog post that shows how to do this: http://weblogs.asp.net/owscott/archive/2009/11/30/iis-url-rewrite-redirect-multiple-domain-names-to-one.aspx. (You'll just need to put the relevant markup in web.config.)

您可以用一个例子规则是:

An example rule you could use is:

    <rule name="cloudexchange" stopProcessing="true">
        <match url=".*" />
        <conditions>
            <add input="{HTTP_HOST}" pattern="cloudexchange.cloudapp.net" />
        </conditions>
        <action type="Redirect" url="http://odata.stackexchange.com/{R:0}" />
    </rule>

这篇关于HTTP重定向为Windows Azure最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆