Panel login after switching to HTTPS

Hello there,

atfer I have switched to HTTPS on my Website I setup my redirects to “non www” to “www only” a and “http” to “https only” I have encountered a problem with me not being able to login into the backend anymore.

If I login with my username and password (which are working 100%, I am able to login when I remove my redirects)
I will not proceed the the backend.

c::set(‘ssl’,‘true’); is in the config file.

I will just stay at the /panel/login page. Im not really sure if I am getting redirected from the backend back the the /panel/login or if im not getting into the backend in the first place.

I have my .htaccess attached…


# Kirby .htaccess

# rewrite rules
<IfModule mod_rewrite.c>

# enable awesome urls. i.e.:
# http://yourdomain.com/about-us/team
RewriteEngine on

# make sure to set the RewriteBase correctly
# if you are running the site in a subfolder.
# Otherwise links or the entire site will break.
#
# If your homepage is http://yourdomain.com/mysite
# Set the RewriteBase to:
#
# RewriteBase /mysite

# In some enviroments it's necessary to
# set the RewriteBase to:
#
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


# block text files in the content folder from being accessed directly
RewriteRule ^content/(.*)\.(txt|md|mdown)$ index.php [L]

# block all files in the site folder from being accessed directly
# except for requests to plugin assets files
#RewriteRule ^assets/plugins/([a-zA-Z0-9\.\-_%=]+)/(.*)$ site/plugins/$1/assets/$2 [L,N]
#RewriteCond $1 !^plugins/[a-zA-Z0-9\.\-_%=]+/assets/.*
RewriteRule ^site/(.*) index.php [L]

# block direct access to kirby and the panel sources
RewriteRule ^(kirby|panel\/app|panel\/tests)/(.*) index.php [L]

# make panel links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^panel/(.*) panel/index.php [L]

# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]

</IfModule>

# Additional recommended values
# Remove comments for those you want to use.
#
# AddDefaultCharset UTF-8
#
# php_flag short_open_tag on

I have now used the www to non www redirect wich is documented in https://github.com/jenstornell/kirby-secrets.
With this Redirect this problem does not come up.

I recommend this read on the subject of www to non www:

Also, you may want to consider setting the url in your config and using a canonical link meta tag instead of redirects.