Windows Azure: How to 301 non-www url to www for a domain Windows Azure: How to 301 non-www url to www for a domain azure azure

Windows Azure: How to 301 non-www url to www for a domain


You are talking about two separate issues here.

The first is to setup a DNS record so that your un-canonised url works. The second is to redirect the url if the site is accessed by it.

update I have removed the previous advice for CNAME from here as I didn't realise before that you cannot set the root domain to a CNAME record. It seems that with the ip restrictions of Azure you will have to point the root domain record at non-azure, asp.net hosting and then put a 301 redirect (such as the one further down my reply) to forward it on to the Azure domain (www domain).

When you have http://coziie.com/ pointing at your site and serving the page its then time to fix this because Google can get confused, think its two different sites and then dilute your page rank between the two.

The trick is to set up a 301 redirect. I believe the url rewriting tool started out as an addon for IIS7 but is now included in it? You might have to do a quick search on that.

Anyway, this is how I do it on an IIS7 server with the official url rewrite extension installed (this goes in your web.config):

  <system.webServer>    <rewrite>      <rules>        <clear/>        <rule name="WWW Rewrite" enabled="true">          <match url="(.*)"/>          <conditions>            <add input="{HTTP_HOST}" negate="true" pattern="^www\."/>          </conditions>          <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent"/>        </rule>      </rules>    </rewrite>  </system.webServer>

Intellisense will complain that its not a recognised element but thats just a cosmetic issue while you are editing the file.


The VIP address is easily obtained by either looking at the portal (read deployment details) or by simply pinging your .cloudapp.net address. You can set an A record, but you must be prepared to update that in case you delete your deployment. Once you delete a deployment, the VIP address will be returned to the pool and there is pretty much a guarantee that you will get a new VIP address on the next deploy.

You can maintain your VIP address by using the Upgrade feature as opposed to new deployments. There are some limitations to this, but it works for updates that do not change the Service Definition broadly speaking.

We used to say that the VIP address was not guaranteed even if you did an update, but MS has come back with stronger language about guarantees. See here.


CNAMES are only for subdomains, like sub.example.com or www.example.com, you can't register a CNAME for example.com in other words. If your domain provider supports it you could create a redirect from example.com to www.example.com and then create a CNAME record for www.example.com, the CNAME will match www.example.com against example.cloudapp.net. My domain provider has a web console where I can do this easily, perhaps yours have too?