I have set up roundcube on a mail.mydomain.com
subdomain using the Apache config example roundcube comes with. Now when I try to reach the root domain on https, it displays the roundcube interface (without redirecting to the subdomain).
# Apache2 vhost configuration sample for Roundcube
# https://linode.com/docs/email/clients/installing-roundcube-on-ubuntu-14-04/
<VirtualHost *:80>
# Virtual host configuration + information (replicate changes to *:443 below)
ServerAdmin tehnic@luckypizza.ro
ServerName mail.luckypizza.ro
ServerAlias mail.laiancu.ro
DocumentRoot /var/www/roundcube
ErrorLog /var/log/apache2/webmail/error.log
CustomLog /var/log/apache2/webmail/access.log combined
# Permanently redirect all HTTP requests to HTTPS
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R=301,L]
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
# Virtual host configuration + information (replicate changes to *:80 above)
ServerAdmin tehnic@mydomain.ro
ServerName mail.mydomain.ro
ServerAlias mail.myotherdomain.ro
DocumentRoot /var/www/roundcube
# ErrorLog /var/log/apache2/webmail/error.log
# CustomLog /var/log/apache2/webmail/access.log combined
# SSL certificate + engine configuration
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/mail.mydomain.ro/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mail.mydomain.ro/privkey.pem
# Roundcube directory permissions + restrictions
<Directory /var/www/roundcube>
Options -Indexes
AllowOverride All
</Directory>
<Directory /var/www/roundcube/config>
Order Deny,Allow
Deny from All
</Directory>
<Directory /var/www/roundcube/temp>
Order Deny,Allow
Deny from All
</Directory>
<Directory /var/www/roundcube/logs>
Order Deny,Allow
Deny from All
</Directory>
</VirtualHost>
</IfModule>
I have replicated this configuration for the root website, like so:
<VirtualHost *:80>
# Virtual host configuration + information (replicate changes to *:443 below)
ServerAdmin tehnic@mydomain.ro
ServerName mydomain.ro
ServerAlias www.mydomain.ro
DocumentRoot /var/www/mydomain/root/public
ErrorLog /var/log/apache2/lucky_error.log
CustomLog /var/log/apache2/lucky_access.log combined
# Permanently redirect all HTTP requests to HTTPS
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R=301,L]
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
# Virtual host configuration + information (replicate changes to *:80 above)
ServerAdmin tehnic@mydomain.ro
ServerName mydomain.ro
ServerAlias www.mydomain.ro
DocumentRoot /var/www/mydomain/root/public
# ErrorLog /var/log/apache2/lucky_error.log
# CustomLog /var/log/apache2/lucky_access.log combined
# SSL certificate + engine configuration
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/mydomain.ro/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.ro/privkey.pem
# Roundcube directory permissions + restrictions
<Directory /var/www/mydomain/root/public>
Options -Indexes
AllowOverride All
</Directory>
</VirtualHost>
</IfModule>
What seems to be wrong with the configurations?