更新1:
我现在有以下几点:
<VirtualHost *:80> ServerName www.companyname.com DocumentRoot /www/html/www.companyname.com/ </VirtualHost> <VirtualHost *:80> ServerName test.companyname.com DocumentRoot /www/html/www.companyname.com/test/ </VirtualHost>
当我在浏览器中input时不起作用
http://test.companyname.com
但是,当我重新启动Apache,我收到一条消息说
Stopping httpd: [ OK ] Starting httpd: [Tue Apr 05 10:49:48 2011] [warn] _default_ VirtualHost overlap on port 80, the first has precedence [ OK ]
原文问题:
我如何configurationApache,所以我可以有我的主要域的许多子域?
例如,谷歌已经
www.google.com mail.google.com docs.google.com
我该如何做同样的事情,但得到子域去网站上不同的目录和/或网页?
我们在RedHat linux上使用LAMPconfiguration。
为每个设置不同的ServerName和DocumentRoot多个VirtualHost 。
<VirtualHost *:80> ServerName www.example.com DocumentRoot /var/www/www.example.com/ # ... other directives ... </VirtualHost> <VirtualHost *:80> ServerName subdomain.example.com DocumentRoot /var/www/subdomain.example.com/ # ... other directives ... <VirtualHost>
我鼓励你看看你现有的configuration文件(在RedHat的/etc/httpd/下,我相信),还要看看Apache的文档 。
如果有人inputhttp://sub1.domain.com ,则会指向http://domain.com/sub1/
解决scheme:RewriteCond%{HTTP_HOST}!^(www | ftp | mail).example.com RewriteCond%{HTTP_HOST} ^([^。] +).example.com RewriteRule(。*)/ subd_%1 / $ 1 [L ]
检查你的.htaccess文件。
你的问题不是那么糟糕,只需要知道你用于服务。