Home > Blockchain >  Second VHost pointing to first on Apache Web Server
Second VHost pointing to first on Apache Web Server

Time:08-26

I followed this tutorial to get Vhosts working on my website. https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04-quickstart. For my second site at reporting.mydev.site, my website still redirects to my main website at mydev.site. I am using Apache as my HTTP server, here are my two .conf files for my main server and my new Vhost.

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName mydev.site
    DocumentRoot /var/www/mydev.site/public_html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

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

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

And here is the .conf file for the vhost I cannot get to work

<VirtualHost *:80>
    ServerName reporting.mydev.site

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/reporting.mydev.site/public_html

  ServerAlias www.reporting.mydev.site

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

CodePudding user response:

I found the problem, the issue was that I needed to create the https version of this file using certbot "reporting.mydev.site-le-ssl.conf". my second vhost was pointing to the first only for the https version but for the http only version it was correctly pointing to my new website.

  • Related