I am hosting multiple sites on the same server with the same ip. I followed the documentation of apache 2.4 (I have apache 2.4.7) hosted on ubuntu 14.04.4Two of the sites work just fine, the other two are missed up. It might be useful to note that I'm using let's encrypt to get https.My Virtual hosts:site1: api.ketabuk.com (works fine)<VirtualHost *:80>        DocumentRoot /var/www/Ketabuk-Server/public        ServerName api.ketabuk.com        ServerAlias api.ketabuk.dev        ServerAdmin webmaster@localhost        <Directory /var/www/Ketabuk-Server>                AllowOverride All        </Directory>        ErrorLog /var/log/apache2/error.log        CustomLog /var/log/apache2/access.log combined</VirtualHost>site2: ketabuk.com (works fine)<VirtualHost *:80>        DocumentRoot /var/www/Ketabuk-Webfront        ServerName ketabuk.com        ServerAlias www.ketabuk.com        ServerAdmin webmaster@localhost        <Directory /var/www/Ketabuk-Webfront>                AllowOverride All        </Directory>        ErrorLog ${APACHE_LOG_DIR}/error.log        CustomLog ${APACHE_LOG_DIR}/access.log combined</VirtualHost>site3: adhamallam.com (goes to api.ketabuk.com instead)<VirtualHost *:80>        DocumentRoot /var/www/adhamallam.com        ServerName adhamallam.com        ServerAlias www.adhamallam.com        ServerAdmin webmaster@localhost        <Directory /var/www/adhamallam.com>                Options Indexes FollowSymLinks                Allow from all                AllowOverride All                Require all granted        </Directory>        ErrorLog ${APACHE_LOG_DIR}/error.log        CustomLog ${APACHE_LOG_DIR}/access.log combinedRewriteEngine onRewriteCond %{SERVER_NAME} =adhamallam.com [OR]RewriteCond %{SERVER_NAME} =www.adhamallam.com#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanen$</VirtualHost>site4: yahyaqandel.com (redirects to adhamallam.com instead)<VirtualHost *:80>        DocumentRoot /var/www/yahyaqandel.com        ServerName yahyaqandel.com        ServerAlias www.yahyaqandel.com        ServerAdmin webmaster@localhost        <Directory /var/www/yahyaqandel.com>                Options Indexes FollowSymLinks                AllowOverride All                Require all granted        </Directory>        ErrorLog ${APACHE_LOG_DIR}/error.log        CustomLog ${APACHE_LOG_DIR}/access.log combinedRewriteEngine onRewriteCond %{SERVER_NAME} =yahyaqandel.com [OR]RewriteCond %{SERVER_NAME} =www.yahyaqandel.comRewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]</VirtualHost>
Apache 2.4 name based virtualhosts goes to the wrong site
apache httpd;apache virtualhost