I have apache on ubuntu 16.4. I create two virtual hosts with different websites but I have problem. One of them shows wrong website. Example:
First VH:
<VirtualHost *:443>
ServerAdmin admin@example.com
ServerName FIRSTWEBSITE.pl
ServerAlias www.FIRSTWEBSITE.pl
DocumentRoot /var/www/FIRSTWEBSITE
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !RC4"
SSLCertificateFile /etc/ssl/certs/FIRSTWEBSITE.crt
SSLCertificateKeyFile /etc/ssl/private/FIRSTWEBSITE.key
SSLCertificateChainFile /etc/ssl/certs/FIRSTWEBSITE.der
</VirtualHost>
Second VH:
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName SECONDWEBSITE.pl
ServerAlias www.SECONDWEBSITE.pl
DocumentRoot /var/www/SECONDWEBSITE
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Now when I type in browser firstwebsite.pl I got second website. Could you help me?
I try to resolve problem by put before <VirtualHost *:443> in config file for first website this one:
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName FIRSTWEBSITE.pl
ServerAlias www.FIRSTWEBSITE.pl
DocumentRoot /var/www/FIRSTWEBSITE
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
But I dont now if its ok. Please help :)
Try this for both the Virtual host
<VirtualHost *:80>
ServerName FIRSTWEBSITE.pl
ServerAlias www.FIRSTWEBSITE.pl
#ServerAdmin admin@example.com
DocumentRoot /var/www/FIRSTWEBSITE
<Directory /var/www/FIRSTWEBSITE>
Options -Indexes +FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.