Z
Z
ZmeY2014-11-06 23:51:41
Apache HTTP Server
ZmeY, 2014-11-06 23:51:41

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

2 answer(s)
S
sHaggY_caT, 2014-11-06
@sHaggY_caT

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.

X
xmoonlight, 2014-11-07
@xmoonlight

NameVirtualHost ip:80

<VirtualHost ip:80>
ServerName test.domain.com
ServerAlias test.domain.com
DocumentRoot /home/www/test.domain.com/www_ssl
</VirtualHost>

(ip = one of the web server's IP addresses.)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question