Apache2 and VirtualHost with foreign characters and more than one Alias

apache-2.2serveraliasvirtualhost

I have a simple apache2 setup with two VirtualHosts. One is a domain name with "normal" characters, and one has foreign characters (with punycode).

The problem is that I don't know how to add "www" as an alias with the punycode domain. With the "normal" one it works fine.

Here's the "normal" host:

ServerName aev25.no
ServerAlias www.aev25.no

I can access the correct site with both the name and the alias.

Here's the "foreign"/punycode host:

ServerName xn--hvin-gra.no
ServerAlias høvin.no

Now, since I haven't got an Alias with "www", it naturally won't work like that. But if I try adding another alias, like this:

ServerName xn--hvin-gra.no
ServerAlias høvin.no
ServerAlias www.høvin.no

or this:

ServerName xn--hvin-gra.no
ServerAlias høvin.no www.høvin.no

it doesn't work. It just opens the default apache2 site. So it seems that this is not the correct way to do it, even though apache2 doesn't complain.

I also have a setup for the domain aev25.no, where the ServerAlias is www.aev25.no. That works fine, which should show that the problem is not related to www.*.:

ServerName aev25.no
ServerAlias wwwaev25.no

(works fine)

So, how do I add another Alias to the domain? Or should I do this another way?

NB: The apache2 version is 2.2.22.

Best Answer

I can't test it but I have a vague recollection of reading somewhere that you need to use punycode in both the ServerName and ServerAlias directives. I would try

ServerAlias    www.xn--hvin-gra.no

I got the www.xn--hvin-gra.no by entering www.høvin.no into a random punycode converter.


I did a simple google search and this is correct apache serveralias punycode