I have got nextcloud working in a VirtualHost (See configuation below). When I only have on virtualhost (nextcloud.conf) enabled in Apache on Ubuntu 16.04, it works. But when I enable the 000-default.conf and the default-ssl.conf it keeps taking me to the main page not the nextcloud page. I have posted all my configuation files. I want to get the default virtualhosts working because I want to catch all urls that don't match the nextcloud config.
nextcloud.conf
<VirtualHost *:80>
ServerName storage.declanmarks.pw
RewriteEngine On
RewriteCond %{HTTP_HOST} ^storage.declanmarks.pw
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
#RewriteRule ^(.*)$ https://storage.declanmarks.pw$1 [R,L]
</VirtualHost>
<VirtualHost *:443>
Alias /files /var/www/files
ServerName storage.declanmarks.pw
DocumentRoot /var/www/nextcloud/
ServerAlias storage.declanmarks.pw
<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud
</Directory>
# SSL
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/storage.declanmarks.pw/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/storage.declanmarks.pw/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/storage.declanmarks.pw/fullchain.pem
Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains;"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
default-ssl.conf
<VirtualHost *:443>
DocumentRoot /var/www/main
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# SSL
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/storage.declanmarks.pw/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/storage.declanmarks.pw/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/storage.declanmarks.pw/fullchain.pem
</VirtualHost>
000-default.conf
<VirtualHost *:80>
DocumentRoot /var/www/main
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>