Redirect http to https not working with NextCloud

Hey all,

Just installed NextCloud and so far it’s great!!

Ran into a small problem though. We’re running:
Apache version 2.4.39
Linux 7.6 kvm
PHP 7.2
NextCloud 16.0.1

Our site is setup using .htaccess to redirect everything to HTTPS. For example if a user types in:
it is automatically redirected to

but if we type in
it is redirected to
without the https.

Of course this gives the onscreen “This connection is not secure…” and the unlocked padlock in the address bar.

As everything else works with our https redirect, is there something in the NextCloud config that we can change to have it always redirect to the https?


why not posting your config.php (and take care to delete sensitive data)?

Hey JimmyKater, actually I looked /Next/config/config.php earlier, but saw nothing relating the the https rewrite, but saw nothing.

Here’s the config.php:

$CONFIG = array (
  'instanceid' => 'ocfbkakb22yj',
  'passwordsalt' => 'xuollgf7ysthkrmopuxlmvp2nlhqel',
  'secret' => 'odzb38xqvdv88qb8bhjogepqdb0yym4pb9msbwyfglyzhv11',
  'trusted_domains' => 
  array (
    0 => '',
  'datadirectory' => '/home/nextuser/Next',
  'dbtype' => 'mysql',
  'version' => '',
  'overwrite.cli.url' => '',
  'dbname' => 'cloud460',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextuser_cloud460',
  'dbpassword' => '@1EJ-S4m6p',
  'installed' => true,



ummm. pls remove at least the ‘secret’ and ‘dbpassword’ - values from your entry. expect them to have become open now and change them.

anyways: thanks for posting the config… i can’'t see anything here neither. but i am no master in it.
would you be so kind and post parts of your nextcloud.log as well? maybe it’ll show some errormessages which might be of help in this case.

Thanks for the advice, this is just a test install with temp users & passwords. I figure after a week of playing with it, things will be so messed up that I will need to do another install :wink:

As for nextcloud.log, I couldn’t find one. I poked through the directories, but nothing. Where should I find the log?

Strange !

Are you using the Apache2 mod_rewrite ?
In your /etc/apache2/sites-available/vhost.conf you should have the following
RewriteEngine on
RewriteCond %{SERVER_NAME} =nextcloud.your.tld
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]

This is smarter, faster than having to deal with htaccess

Thanks for chirping in, however this is Greek to me!! Linux servers are not my forte - by any stretch.

I’ll need to check with our hosting provider to follow up on the vhost.conf file.

It is really strange to me too. FInally when I thought I figured out how to carefully craft the https redirect using .htaccess the whole thing is becoming a hair-puller!
I’ll keep poking and let you know what I come up with.

It seems it’s solved.

The excellent tech support from the folks at ChemiCloud hosting, poked and prodded and found the problem.

In this case the .htaccess rewrite needed to be in the Nextcloud installation folder, not at the public_html level. Although all other subdirectory redirect works with the rewrite code in the public_html .htaccess file, Nextcloud needs it to be in the Nextcloud installation directory.

Thanks to everyone that pitched in on this.

yes, the problem with htaccess config, is that you need several htaccess. this is annoying and complicated.
This is a multi-conf management.

you can simply let your apache2 server do it via mod_rewitte directly in the server conf
it a whole server conf management.

I have

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

and it works

My Nextcloud is on an Ionos Webspace!
In what file to put Your Text?
Pls tell me directory and file to be 100% sure