Hosting Übersites: IIS7 Support for International Domain Names (IDN)
Let's suppose you are German, you developed an extremely cool web-site and now you want to make it available to your German Bier buddies. The only really fetzig site name you could come up with contains one of these nasty German umlauts: übersite.de (not registered at the time I'm writing this blog).
There are several registrars out there who allow you to register domain names that contain Unicode characters. It's called International Domain Names (IDN) and IIS 7.0 and HTTP.SYS support it nicely.
Here is what you do if you want to try it yourself:
1) Configure IE to use IDN server names for Intranet addresses
You need a browser who converts IDNs into punycode. Name resolution systems like DNS don't work with Unicode and hostnames have to be converted to punycode first. Internet Explorer 7 does this automatically for Internet addresses. For our example you need to instruct IE to do the same for Intranet addresses. Go to "Tools" - "Internet Options" - select the "Advanced" tab and scroll down to the "International" section. Check "Send IDN server names for Intranet addresses".
2) Generate the Punycode representation of your site name
We need to convert the IDN site name to Punycode because existing name resolution systems still live in the good old ASCII world. There are a couple of web sites out there which do Unicode-to-Punycode conversions. Here is one of them: http://www.nameisp.com/puny.asp
The resulting punycode string for übersite.de looks like this: xn--bersite-m2a.de
3) Registration of punycode name in name system
To keep name registration simple we register übersite.de in our hosts file only. This will resolve the site name for local requests.
Open %windir%\system32\drivers\etc\hosts
Add a new line at the end and add the following:
127.0.0.1 xn--bersite-m2a.de
Save and close notepad. The punycode representation of übersite.de is now mapped to your local loopback adapter 127.0.0.1
4) Add a new site in IIS
Almost there. The only thing left to do is to add übersite.de to IIS. Here are the commands I run in cmd.exe (make sure you run in an elevated command shell):
md %systemdrive%\übersite
echo This is the Default Document of übersite.de >> %systemdrive%\übersite\default.htm
%windir%\system32\inetsrv\appcmd add site -site.name:übersite -bindings:http://übersite.de:80 -physicalPath:%systemdrive%\übersite
5) Request übersite.de
Now you just have to enter übersite.de into the address bar of Internet Explorer.
And in case you have no idea how to enter "ü" on your keyboard: turn on NumLock and enter <Alt>+0252. International Domain names of course do not just work for German Bier buddies but for all characters that can be represented via Unicode characters.
Credits: thanks to Jeong Hwang Kim who gave me the idea to this blog entry.