Virtual Host Subsites apache 2.4
I'm setting up 2 wordpress sites. The scenario is that there are two Wordpress installations, in the folder var/www/domain/us and var/www/domain/eu. The domain.com/us should be the default option when you access the site from domain.com
Users access the site through: domain.com/us or domain.com/eu
Right now the setup for virtual host is: (I don't have a real domain name attached, so its only IP address so far)
ServerAlias IP
DocumentRoot /var/www/domain/us
ErrorLog /var/www/html/domain.com/logs/error.log
CustomLog /var/www/html/domain.com/logs/access.log combined
DocumentRoot /var/www/domain/us
ServerAlias IP
ErrorLog /var/www/html/domain.com/logs/error.log
CustomLog /var/www/html/domain.com/logs/access.log combined
DocumentRoot /var/www/domain/eu
ServerAlias IP
ErrorLog /var/www/html/domain.com/logs/error.log
CustomLog /var/www/html/domain.com/logs/access.log combined
I can access the IP address with the primary virtual host, but the last two IP/us and IP/eu is giving Page not found.
What am I doing wrong?
1 Reply
In the context of a single IP address this will not work without a domain name. Name based virtual hosts are determined based on server name and server alias which cannot contain a "/". The name directive is not a pointer to a folder it is a fully qualified name (or a locally resolvable name) such as "eu.example.com" and the server retrieves the files based on the DocumentRoot directive.
Valid ServerName: eu.linode.com
invalid ServerName: linode.com/eu
Valid URL linode.com/eu (path based) OR eu.linode.com (named based)
One option to load example.com …US by default… use a standard vhost with a folder for US and EU. Have the index load US assets and use the URL
-- Index (pulls US assets)
| ---US (folder)
|---EU (folder)
|||-- Index (pulls EU assets)
ServerAlias IP
DocumentRoot /var/www/domain/
ErrorLog /var/www/html/domain.com/logs/error.log
CustomLog /var/www/html/domain.com/logs/access.log combined