V
V
volxw2014-07-21 14:47:05
Apache HTTP Server
volxw, 2014-07-21 14:47:05

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

2 answer(s)
A
Alexander, 2014-07-21
@SashaSkot

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
# ...

V
volxw, 2014-07-21
@volxw

I had the Rewrite Engine in mind when I wrote this question, but thought there was a more "direct" way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question