大网数据广告活动
服务器运维问答

apache2 and VirtualHost with foreign characters and more than one Alias

· 52CE 我爱测

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 d…

问题原文

原帖链接 · Frank H. · CC BY-SA 3.0

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.

已采纳解答

原帖链接 · user9517 · CC BY-SA 3.0

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-03-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。