Question

Virtual hosts redirecting to wrong domain

I had multiple virtual hosts and everything was working perfectly, I added an extra one today and now all my previous hosts redirect to the new one.

This is what I get when I run apache2ctl -S

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
104.131.79.162:443     domain1.com (/etc/apache2/sites-enabled/domain1.com-le-ssl.conf:2)
104.131.79.162:80      domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:2)
*:443                  is a NameVirtualHost
         default server domain2 (/etc/apache2/sites-enabled/domain2.com-le-ssl.conf:2)
         port 443 namevhost domain2.com (/etc/apache2/sites-enabled/domain2.com-le-ssl.conf:2)
                 alias www.domain2.com
         port 443 namevhost domain3.com (/etc/apache2/sites-enabled/domain3.com-le-ssl.conf:2)
                 alias www.domain3.com
         port 443 namevhost domain4.com (/etc/apache2/sites-enabled/domain4.com-le-ssl.conf:2)
                 alias www.domain4.com
         port 443 namevhost domain1.com (/etc/apache2/sites-enabled/domain1.com-le-ssl.conf:2)
                 alias www.domain1.com
                 alias domain1.com
*:80                   is a NameVirtualHost
         default server domain2.com (/etc/apache2/sites-enabled/domain2.com.conf:1)
         port 80 namevhost domain2.com (/etc/apache2/sites-enabled/domain2.com.conf:1)
                 alias www.domain2.com
         port 80 namevhost domain3.com (/etc/apache2/sites-enabled/domain3.com.conf:1)
                 alias www.domain3.com
         port 80 namevhost domain4.com (/etc/apache2/sites-enabled/domain4.com.conf:1)
                 alias www.domain4.com
         port 80 namevhost domain1.com (/etc/apache2/sites-enabled/domain1.com.conf:2)
                 alias www.domain1.com
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

Any idea what’s going on and how I can fix it?


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.

Hello,

can you post the new virtual host you added? Additionally, can you confirm if you added it to /etc/apache2/sites-available and /etc/apache2/sites-enabled``` or somewhere else?

Do the previous virtual host files follow the same rules as well?

Regards, KFSys

This comment has been deleted