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.

  • 1
    Have you got your dns configured for the alias? Does www.høvin.no resolve to the server ip address? – Diamond Mar 8 '16 at 12:40
  • Yes, the dns is correct. I just edited that into the post, since I forgot to mention it. høvin.no opens the correct site, while www.høvin.no just opens the default apache site ("default" from sites-available/enabled). – Frank H. Mar 8 '16 at 13:06
  • Can you rename default-site file to something like z-default, to make sure it is processed at last, and see if it helps? – Diamond Mar 8 '16 at 14:34
  • Not sure if I know what you mean. Do you mean rename /etc/apache2/sites-enabled/000-default? If so, I tried that during the troubleshooting, and it didn't have any effect on anything. The way this version of apache2 works - possibly all newer versions? - is that I try accessing a sub domain or alias for a site that doesn't exist, it defaults to the default page. What I know is that høvin.no works, as the correct site is opened. But any extra Aliases - www.høvin.no, test.høvin.no etc - just opens the default page. – Frank H. Mar 8 '16 at 14:43
  • I also forgot to mention: I have a similar setup for the domain aev25.no, where www.aev25.no is the ServerAlias. That works fine, so the problem is not related to www.* I'd say. – Frank H. Mar 8 '16 at 16:25

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

  • 1
    This is correct; the reason is that translation from UTF-8 to punycode happens in the client, not in apache. You would have to use the same conversion in e.g. nginx. See w3.org/International/articles/idn-and-iri for links to the relevant RFCs. – Jenny D Mar 8 '16 at 18:57
  • You're right. That was the only thing I didn't try yet because I read that you should NOT use punycode in the ServerAlias. – Frank H. Mar 8 '16 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.