Force https site

I have a site with version 3.2.2 but it is not automatically redirecting to the https version of the site nor the panel. I did set SSL true in my config. I there a way to force the https site?

my config file looks like this:

<?php
return [
	'debug' => false,
	'ssl' => true
];

There is no SSL option in Kirby 3. You can set the URL: https://getkirby.com/docs/reference/system/options/url

But enforcing HTTPS should happen in your server config file or in your .htaccess if you don’t have access to the server configuration or in your hosting’s panel.

1 Like

Just for completeness, you can paste this in your .htaccess file right below # RewriteBase /

#redirect http to https
<IfModule mod_rewrite.c>
 RewriteCond %{HTTPS} off
 RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

Only reason I’m adding this is because some implementations don’t correctly redirect. For example,
http://example.com/panel/login
would redirect to
https://example.com/index.php

As @texnixe mentioned, HTTP to HTTPS redirection should only be performed in .htaccess if you do not have access to the server or virtual host configuration file, see When not to use mod_rewrite.

If you do have access to the config, the recommended way is

<VirtualHost *:80>
    ServerName www.example.com
    Redirect "/" "https://www.example.com/"
</VirtualHost>

<VirtualHost *:443>
    ServerName www.example.com
    # ... SSL configuration goes here
</VirtualHost>

And if you prefer a permanent redirection replace the sole word “Redirect” with “Redirect 301” or “Redirect permanent” or “RedirectPermanent”, which are all equivalent, but Redirect alone will do a temporary or 302 redirection.