在我的Vserver Id喜欢configuration一个子域名。 所以我有我的apache虚拟主机configuration下面的条目。 我想让我的网站app1.example.com作为自己的网站运行,以便网页和文件具有域名,例如app1.example.com/photo.jpg或app1.example.com/blog/ 。
<VirtualHost *:80> DocumentRoot /var/www/app1 ServerName app1.example.com <VirtualHost> <VirtualHost *:80> DocumentRoot /var/www/example ServerName example.com <VirtualHost> <VirtualHost *:80> DocumentRoot /var/www/wildcard ServerName other.example.com ServerAlias *.example.com <VirtualHost>
但为什么我需要这样的DNS呢? 不要我已经在我的虚拟主机configuration设置?
Host Type Destination app1 A 78.xx.xx.xx (my IP) * A 78.xx.xx.xx
或者我需要指向目标这样的目录:app1.example.com Thx for advise!
如果你有一个通配符logging指向你的子域的IP,你将不需要更具体的app1 Alogging,通配符会照顾到这一点。 用户的浏览器发送:
Host: app1.example.com
当它向该域请求时,Apache就知道客户端需要哪个域。 通配符logging会告诉浏览器将该请求发送到您的服务器。
嗯,我认为也许这个问题的一部分是在设置DocumentRoot中使用'='。 除非这是一些很less使用的替代语法,否则apache文档似乎build议使用“DocumentRoot / foo / bar”之类的地方,其中/ foo / bar是所需的文档根目录。 请参阅http://httpd.apache.org/docs/2.1/mod/core.html#documentroot 。 关于你的dns问题,用户的浏览器将发送主机头,如果你有NameVirtualHosts指令设置,将会使用匹配的ServerName或ServerAlias的VirtualHost指令。 您可以使用通配符“*”条目或特定条目或两者都configuration您的DNS服务器 – 浏览器仍将发送适当的主机头。