Answer the question
In order to leave comments, you need to log in
How to allocate a subdomain to a separate virtual host?
Good afternoon!
There is a site, domain name, for example, domain.com
Apache virtual host config file (simplified, square brackets, not angle brackets, because the site parser "eats" them, thinking that they are tags):
####### #########
NameVirtualHost *:80
[VirtualHost *:80]
ServerName domain.com
DocumentRoot /home/www/domain.com/www
[/VirtualHost]
############ ####
I want to allocate one of the subdomains ( test.domain.com ) into a separate site with a separate root directory (on the same server, the ip-address is the same as the main domain)
##########
[VirtualHost * :80]
ServerName test.domain.com
DocumentRoot /home/www/test.domain.com/www_ssl
[/VirtualHost]
##########
but when accessing test.domain.com, I still get to the root of the domain.com
site,
which I do not this way?
Answer the question
In order to leave comments, you need to log in
Make the first (in the config) any other (test) domain, and check that when you try to open any domain, your test one, specified first, opens. most likely it will be so.
In general, third-level domains are described in exactly the same way as first-level domains.
NameVirtualHost ip:80
<VirtualHost ip:80>
ServerName test.domain.com
ServerAlias test.domain.com
DocumentRoot /home/www/test.domain.com/www_ssl
</VirtualHost>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question