Why is my Apache VirtualHost directing to the wrong VirtualHost?

On an existing wordpress-installed droplet, I am installing a new wordpress instance (two wordpress installs in same droplet).

To do so, I followed the answer by ryanpq on this thread:

Similar to the commenters on that thread, my newer site redirects to my existing site (even after changing the DocumentRoot and Directory appropriately).

Here are my configs:

Within /etc/apache2/sites-enabled, I have 4 files: 000-default-le-ssl.conf 000-default.conf example1.conf example2.conf
000-default.conf and example1.conf` are copies.

example1.conf looks like so:

# Added to mitigate CVE-2017-8295 vulnerability
UseCanonicalName On

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        <Directory /var/www/html/>
            Options FollowSymLinks
            AllowOverride None
            Require all granted

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} [OR]
RewriteCond %{SERVER_NAME}
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

example2.conf looks like so:

<VirtualHost *:80>
        DocumentRoot /var/www/example2

        <Directory /var/www/example2/>
            Options FollowSymLinks
            AllowOverride All
            Require all granted

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

my directory structure looks like /var/www/html and /var/www/example2

Within the control panel of my DO account, I created a new project for my newly acquired domain name.
I created new A and CNAME records. The A record points to the IP address of the older, existing, site (so, directs to 128…)

Additional: I noticed while following the user ryanpq’s answer, that the wordpress install I did only had a wp-config-sample.php, so I copied that file, named it wp-config.php and filled it in with the database info.

What am I missing?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi there @theindiman,

The configuration looks all correct. It is possible that the permissions of the /var/www/example2 are not correct. What you need to do is make sure that the Apache user has read and write permissions to that folder:

  1. sudo chown www-data:www-data /var/www/example2

Also I could suggest checking your Apache error log for more information:

  1. sudo tail -100 /var/log/apache2/error.log

And one more thing, is the example2com site a copy of the original site or a fresh new WordPress installation?

Regards, Bobby