How to force nextcloud to use HTTPS

I hope all are safe.

How can I force nextcloud to redirect to https?

I tried to use

Force HTTPS overwrite

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

but HTTP traffic is not redirected to HTTPS.

I’m hosting on shared hosting.

Can someone help me?

Thank you

.htaccess works for me:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{ENV:HTTPS} !=on
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

With certbot and Lets Encrypt it is automatic better configured in apache2-conf.

I hate that obfuscated “rewrite” nonsense. It’s hard to read and debug.

Instead, my vhosts.conf uses a clear:

<VirtualHost *:80>
    Redirect permanent /

That is clear and easy to understand. I hope that helps!

1 Like