Virtual Host Subsites apache 2.4

Hi,

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)

ServerName IP

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

ServerName IP/us

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

ServerName IP/eu

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

Howdy.

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 http://site.com/eu for eu version. Once you have a domain you could use two name based virtual hosts with no issue.

-- Index (pulls US assets)

| ---US (folder)

|---EU (folder)

|||-- Index (pulls EU assets)

ServerName IP

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

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct