I setup an https redirect in owncloud.conf under /etc/apache2/sites-available, enabled it and restarted apache. The https redirect works but only if I disable both: 000-default.conf & default-ssl.conf and type http://owncloud.jam.lan/owncloud in my web browser. This leads me to believe I have set something up wrong.
Enabling 000-default.conf and default-ssl.conf and typing: owncloud.jam.lan into my web browser I get the: “It Works! Apache2 Ubuntu Default Page” If I type: owncloud.jam.lan/owncloud into my web browser then I get:
The requested URL /owncloud was not found on this server.
Apache/2.4.29 (Ubuntu) Server at owncloud.jam.lan Port 443
Disabling both: 000-default.conf and default-ssl.conf allows me to access ownCloud. Going to owncloud.jam.lan I can access ownCloud but via http which is unacceptable as I do not want anyone accessing ownCloud via http.
But going to: owncloud.jam.lan/owncloud I am then redirected to https (even if I type http://owncloud.jam.lan/owncloud in my web browser). I’ve looked through the Apache manual and tried several of the examples they give but no luck and right now I’m just not understanding all the Apache directives, their hierarchy and how Apache “actually” interprets them. I would also like to keep the: “Redirect permanent” directive as the Apache manual says the: “mod_rewrite should be considered a last resort”. Any help would be greatly appreciated!
<VirtualHost *:80> Alias /owncloud "/var/www/owncloud/" ServerName http://owncloud.jam.lan/owncloud DocumentRoot /var/www/owncloud Redirect permanent /owncloud https://owncloud.jam.lan/owncloud </VirtualHost> <VirtualHost _default_:443> Alias /owncloud "/var/www/owncloud" ServerName https://owncloud.jam.lan/owncloud DocumentRoot /var/www/owncloud SSLEngine On SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key </VirtualHost>