Report this

What is the reason for this report?

Domain mapping WordPress multisite with Apache

Posted on March 10, 2021

I setup a WordPress multisite on Ubuntu 20.04 using Apache and I’m having trouble getting a domain pointing to the right website. I have a static html website running as well and my directory tree is as follows:

/var/www/
  site1 
  wordpress-multisite // site2 & site3

I have 3 domains with DigitalOcean: site1.com, site2.com, and site3.com. All 3 point to the droplet and site2 includes a wildcard because it’s the primary for the multisite. site1.com displays the static website which is correct. site2.com displays one of the WordPress multisite, also correct. site3.com displays the static website (site1).

I have my virtual hosts for apache2 setup within /etc/apache2/sites-available as follows:

// site1.conf
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName site1.com
    ServerAlias www.site1.com
    DocumentRoot /var/www/site1
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.site1.com [OR]
RewriteCond %{SERVER_NAME} =site1.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

//wordpress-multisite.conf
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName site2.com
    ServerAlias *.site2.com
    DocumentRoot /var/www/wordpress-multisite
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =site2.com [OR]
RewriteCond %{SERVER_NAME} =www.site2.com [OR]
RewriteCond %{SERVER_NAME} =site3.com [OR]
RewriteCond %{SERVER_NAME} =www.site3.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

When this did not works I added a site3.conf and enabled it within apache with sudo a2ensite site3.conf and restarted apace, no luck.

Am I missing something with the virtual hosts? Does the Wordpress installation need to be in a html directory? It’s boggling my mind that site3.com is pointing to the wrong directory when I have it pointing to the correct one.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.