Mlody87
Mlody87

Reputation: 435

One virtualhost shows website from other virtualhost

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 [email protected]
    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 [email protected]
    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 [email protected]
    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 :)

Upvotes: 1

Views: 398

Answers (1)

Monish Khatri
Monish Khatri

Reputation: 980

Try this for both the Virtual host

<VirtualHost *:80>
    ServerName FIRSTWEBSITE.pl
    ServerAlias www.FIRSTWEBSITE.pl
    #ServerAdmin [email protected]
    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>

Upvotes: 1

Related Questions