LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache VirtualHost's (http://www.linuxquestions.org/questions/linux-server-73/apache-virtualhosts-850688/)

Dreft 12-16-2010 11:04 AM

Apache VirtualHost's
 
Hello. I created VirtualHost in apache configuration file.

Code:

NameVirtualHost 77.79.13.20:80

<VirtualHost 77.79.13.20:80>
  DocumentRoot "/var/www/host"
  ServerName host.t2p.lt
</VirtualHost>

Now, http://host.t2p.lt works perfect, take site visitor to exact page - www.t2p.lt/host/

but if I do http://www.host.t2p.lt it take visitor to www.t2p.lt page.

Whats wrong and what should I include ?



Sorry for thread, I just must include this:
Code:

<VirtualHost 77.79.13.20:80>
  DocumentRoot "/var/www/host"
  ServerName www.host.t2p.lt
</VirtualHost>

And works perfect.

Noway2 12-16-2010 02:55 PM

The host name to ip resolution is a typically DNS function. For example you would want an A record to host.t2p.lt and a CNAME for www.host.t2p.lt that points to the same address. In your Apache configuration you can use an ALIAS directive for the host, which will tell Apache that the particular host file is for both host.t2p.lt and www.host.t2p.lt, but it requires that these addresses both resolve to the same location.


All times are GMT -5. The time now is 02:47 AM.