Nextcloud redirects to


I installed Nextcloud on Debian 12.5. I was able to log in the first time and configure Nextcloud. I then set up and configured an SSL certificate with LetsEncrypt. That worked fine too.
However, when I try to get to the login page now, I’m getting redirected to I initially had that url in my nextcloud.conf file in the Redirect permanent line. I subsequently changed it to the correct url.

Here is my nextcloud.conf file (urls edited for security):

<VirtualHost *:80>
    Redirect permanent /
    DocumentRoot /var/www/html/nextcloud/
    <IfModule mod_headers.c>
      Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
        Alias /nextcloud "/var/www/html/nextcloud/"

    # log files
    ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log
    CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined

    <Directory /var/www/html/nextcloud/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
        <IfModule mod_dav.c>
            Dav off

    # SetEnv HOME /var/www/html/nextcloud
    # SetEnv HTTP_HOME /var/www/html/nextcloud

RewriteEngine on
RewriteCond %{SERVER_NAME}
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

The output of your config.php file (edited for security):

$CONFIG = array (
  'instanceid' => 'whatever',
  'passwordsalt' => 'whatever',
  'secret' => 'whatever',
  'trusted_domains' =>
  array (
    0 => '',
  'datadirectory' => '/var/www/html/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '',
  'overwrite.cli.url' => '',
  'overwriteprotocol' => 'https',
  'dbname' => 'nextclouddb',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloudusername',
  'dbpassword' => 'not for your eyes',
  'installed' => true,

Let me know if I can provide anything else to resolve this problem. I appreciate any help you can give me.

It shouldn’t be the source of your problem, however you have so many things in your VirtualHost, something like

<VirtualHost *:80>
	RedirectMatch permanent ^/(.*)$$1

should be enough. I wouldn’t even set a DocumentRoot so it will be just impossible to reach Nextcloud without SSL (even if your redirect conditions fail).

(from the examples here: How To Create Temporary and Permanent Redirects with Apache | DigitalOcean).

Then I’d try to access via curl and check if the http request goes to https of your domain. Or if that already redirects to, or if that appears later.


@tflidd Thanks for responding so quickly. Much appreciated.

Here is the curl out put I’m getting:

Not sure where the is coming from. I looked all over the nextcloud directory and I couldn’t find it.

1 Like

First try the curl with http, not https. Just to check your first redirect.

Then the next step is to check the VHost for the https connection.

You can also check if anything in your config points to

grep -nri '' /etc

Maybe this is a silly question, but isn’t the domain name you actually use for your Nextcloud, is it? I’m asking because this domain name redirects to, where actually a Nextcloud is running :wink:

<!DOCTYPE html>
<meta http-equiv="Refresh" content="0;url="/>
<title>301 Moved Permanently</title>
<script type="text/javascript">window.location.href="";</script>

Please also check the apache’s access_log, whether the request really arrives it.
btw.: Also check the other sites-enabled/*.conf files.
Is your nextcloud.conf enabled? - See sites-enabled folder.

@bb77 Correct, in not the actual domain name for the site. It’s a placeholder for security.

I found the problem. I was working with the wrong conf file. I was always working on nextcloud.conf. When I set up SSL with LetsEncrypt it created the file nextcloud-le-ssl.conf. I fixed the redirection there.
All good now.

Thanks for everyone’s help. Really appreciate it.

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.