Answer the question
In order to leave comments, you need to log in
How to link a subdomain to a virtual host?
Hey!
Our company faced the task of creating a test environment for web development.
The following configuration turned out:
- Apache on Ubuntu.
Added virtual host project1.server
- DNS server on Windows Server 2012. Added A-record server.corp.domain.local and CName-record for this A-record respectively project1.server.corp.domain.local
directory for /var/www/project1 for host project1.server
In the grid, when server.corp.domain.local is requested, sends to /var/www/
when project1.server.corp.domain.local is requested there
How to tell Apache to by subdomain name sent to the desired virtual host?
Answer the question
In order to leave comments, you need to log in
Alternatively, create an additional virtual host with the server name:
NameVirtualHost 172.20.30.40
# primary vhost
DocumentRoot /www/subdomain
RewriteEngine On
RewriteRule ^/.* /www/subdomain/index.html
# ...
DocumentRoot /www/subdomain/sub1
ServerName www.sub1.domain.tld
ServerPath /sub1/
RewriteEngine On
RewriteRule ^(/sub1/.*) /www/subdomain$1
# ...
DocumentRoot /www/subdomain/sub2
ServerName www.sub2.domain.tld
ServerPath /sub2/
RewriteEngine On
RewriteRule ^(/sub2/.*) /www/subdomain$1
# ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question