Question

Domain incorrectly redirects to another domain (both hosted on droplet)

Hi, I am hosting two sites, site1 and site2, on my droplet. Both domains directed to the appropriate content until I restarted apache.

I believe there is something incorrect with the conf files but I cannot identify the error. Can anyone assist with pointing it out?

site1 conf file: <VirtualHost *:80> ServerAdmin admin@site1.com ServerName site1.com ServerAlias www.site1.com/ DocumentRoot /var/www/wordpress ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined

<Directory /var/www/wordpress/> AllowOverride All </Directory>

RewriteEngine on RewriteCond %{SERVER_NAME} =site1.com [OR] RewriteCond %{SERVER_NAME} =www.site1.com/ [OR] RewriteCond %{SERVER_NAME} =www.site1.com RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] </VirtualHost>

site2 conf file: <VirtualHost *:80> ServerAdmin admin@site2.com ServerName site2.com ServerAlias www.site2.com/ DocumentRoot /var/www/site2.com ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined

<Directory /var/www/site2.com/> AllowOverride All </Directory> </VirtualHost>

DNS settings are: site1: A *.site1.com directs to serverIP A site1.com directs to serverIP A www.site1.com direts to serverip NS1 NS2 NS3

site2: A *.site2.com directs to serverIP A site2.com directs to serverIP NS1 NS2 NS3

Subscribe
Share

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

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.

Hi I have exactly the same problem. Please help!

Try removing the trailing slash in both ServerAlias directive and restart Apache.

Regards