I have 2 separate domains that I want to host 2 different servers on. I have both conf files set up, but the problem is; going to my second domain in my browser sends me to the first virtual host and all its files. I'm not sure what can cause this, because I'm new to most apache things, so I will put both conf files here.
Site 1:
NameVirtualHost *:80
Listen *:80
<VirtualHost *:80>
ServerAdmin admin@site1.example
ServerName site1.example
ServerAlias www.site1.example
DocumentRoot /var/www/site1.example/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Site 2:
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
NameVirtualHost *:443
Listen 443
<VirtualHost *:443>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/%1 [R,L]
ServerName site2.example
ServerAlias *.site2.example
ErrorLog ${APACHE_LOG_DIR}/site2/SSL_error.log
TransferLog ${APACHE_LOG_DIR}/site2/SSL_access.log
VirtualDocumentRoot "/var/www/site2/%1"
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:!LOW:!aNULL:!eNULL
SSLCertificateFile /etc/letsencrypt/live/site2.example/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/site2.example/privkey.pem
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
SSLOptions +StdEnvVars
</Files>
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0~
<Directory /var/www/site2.example>
Options +Indexes +FollowSymLinks -MultiViews
UseCanonicalName Off
AllowOverride All
Allow from all
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.site2\.example$ [NC]
RewriteCond /var/www/site2.example/%1 !-d
RewriteRule ^(.*) https://404.site2.example/
</Directory>
<Directory /var/www/site2.example/%1>
Options +Indexes +FollowSymLinks -MultiViews
UseCanonicalName Off
AllowOverride All
Allow from all
</Directory>
<Location />
UseCanonicalName Off
Order allow,deny
Allow from all
</Location>
</VirtualHost>
From this, what I mean is that Site 2 is sending me to Site 1, not as a redirect, but actually loads all of its files. Perhaps I did something wrong? When I set Site 2's port to 80, it tells me "Your browser sent a request that this server could not understand. Reason: You're speaking plain HTTP to an SSL-enabled server port. Instead use the HTTPS scheme to access this URL, please" even when using https://