logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Apache VirtualHost - configure sub-domains?
Author
Express



Joined: 07 Jan 2013
Posts: 34

PostPosted: Mon 14 Jan '13 2:35    Post subject: Apache VirtualHost - configure sub-domains? Reply with quote

I have substituted the domain names and DocumentRoot folders for generic titles, so I will refer to those where applicable in the thread as well.

First thing is first, here is my httpd-vhosts.conf:
Quote:
<VirtualHost *:80>
DocumentRoot "C:\WebServer\www"
</VirtualHost>

<VirtualHost *:80>
ServerName www.domain1.tld
DocumentRoot "C:\WebServer\www\domain1"
ServerAlias domain1.tld
</VirtualHost>

<VirtualHost *:80>
ServerName sub1.domain1.tld
DocumentRoot "C:\WebServer\www\domain1\sub1"
ServerAlias www.sub1.domain1.tld
</VirtualHost>

<VirtualHost *:80>
ServerName sub2.domain1.tld
DocumentRoot "C:\WebServer\www\domain1\sub2"
ServerAlias www.sub2.domain1.tld
</VirtualHost>

<VirtualHost *:80>
ServerName sub3.domain1.tld
DocumentRoot "C:\WebServer\www\domain1\sub3"
ServerAlias www.sub3.domain1.tld
</VirtualHost>

<VirtualHost *:80>
ServerName www.domain2.tld
DocumentRoot "C:\WebServer\www\domain2"
ServerAlias domain2.tld *.domain2.tld
</VirtualHost>

<VirtualHost *:80>
ServerName www.domain3.tld
DocumentRoot "C:\WebServer\www\domain3.tld"
ServerAlias domain3.tld *.domain3.tld
</VirtualHost>

<VirtualHost *:80>
ServerName www.domain4.tld
DocumentRoot "C:\WebServer\www"
ServerAlias domain4.tld *.domain4.tld
</VirtualHost>

Legend:
domain[X as number] = domain name
sub[X as number] = sub-domain name
tld = duh?
domain2, domain3 and domain4 I guess can be ignored (i think?).

Right, now that I have posted that...the matter at hand is this:

Basically what I want to know is how can I make certain sub-domains of domain1.tld point to subfolders of the domain's DocumentRoot. This seems to half work and half not work (for some and not for others). Should the way it's configured there work as intended or not?

I preferably want domain1.tld to catch requests to any sub-domain that does not exist as well, but I do not know if that is at all possible...?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7294
Location: Germany, Next to Hamburg

PostPosted: Thu 17 Jan '13 15:14    Post subject: Reply with quote

Just use a vhost with a ServerAlias *.domain1.tld

or use a vhost for all not configured vhosts.

See
http://httpd.apache.org/docs/2.4/vhosts/examples.html#default
Back to top


Reply to topic   Topic: Apache VirtualHost - configure sub-domains? View previous topic :: View next topic
Post new topic   Forum Index -> Apache