<VirtualHost *:80>
    ServerName lencraftserver.de
    DocumentRoot /var/www/datanet

    Alias /.well-known/acme-challenge/ /var/www/datanet/.well-known/acme-challenge/
    <Directory "/var/www/datanet/.well-known/acme-challenge/">
        Options None
        AllowOverride None
        Require all granted
    </Directory>

    RewriteEngine On 
    RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/
    RewriteRule ^ https://www.lencraftserver.de%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>

<VirtualHost *:80>
    ServerName www.lencraftserver.de
    DocumentRoot /var/www/datanet

    Alias /.well-known/acme-challenge/ /var/www/datanet/.well-known/acme-challenge/
    <Directory "/var/www/datanet/.well-known/acme-challenge/">
        Options None
        AllowOverride None
        Require all granted
    </Directory>

    RewriteEngine On 
    RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/
    RewriteRule ^ https://www.lencraftserver.de%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>

<VirtualHost *:443>
    ServerName lencraftserver.de
    Redirect permanent / https://www.lencraftserver.de/

    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/lencraftserver.de/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/lencraftserver.de/privkey.pem
</VirtualHost>

<VirtualHost *:443>
    ServerName www.lencraftserver.de
    DocumentRoot /var/www/lencraftstudios

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

    <Directory /var/www/lencraftstudios>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    RewriteEngine On
    RewriteCond %{QUERY_STRING} (^|&)utm_ [NC]
    RewriteRule ^ - [E=HAS_UTM:1]
    CustomLog /var/log/apache2/utm_access.log combined env=HAS_UTM

    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/lencraftserver.de/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/lencraftserver.de/privkey.pem

#    DocumentRoot /var/www/datanet/sources/backend/error
#    ErrorDocument 404 https://api.datanet.lencraftserver.de/backend/error/index.html
</VirtualHost>
