Apache vhost_alias

572 views Asked by At

I have a question about vhost_alias

I got it working, it does the following job:

vhost.subdomain.domain.com -> sends to /var/www/vhost

using virtualdocumentroot and %1

But I don't like that I can access the same content also like this

vhost.vhost.subdomain.domain.com

since I have ServerAlias to *.subdomain.domain.com

How can I force that only vhost.subdomain.domain.com works?

The aim is to have many vhosts like this, for exmaple vhost1, vhost2, etc.

Thanks, David

1

There are 1 answers

0
Go0se On

One solution you could try is to add a fixed subdomain in your ServerAlias, before your actual dynamic subdomain:

Example:

ServerAlias www.*.subdomain.domain.com

This will ensure that

vhost.vhost.subdomain.domain.com

does not redirect, however, you will be forced to always add www. before your name.