Can’t login to panel after changing .htaccess

Hi there,

yesterday we went live and it works quite well so far. I had to adjust the htaccess file to redirect all non-www traffic to www.*

Now I can’t login to panel anymore. When I click on “Login”, I do not see a error message, but the login page refreshes and form fields are cleared.
What can I do?

htaccess file:
# 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 /

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [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
RewriteRule ^site/(.*) index.php [L]

# block all files in the kirby folder from being accessed directly
RewriteRule ^kirby/(.*) 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>

Thanks in advance, Martin.

You could try to set the

Thanks, I tried all combinations of the ssl and url option, but I still can’t login.
I had ssl = true all the time. Any other ideas?

Does it work again if you uncomment the two lines in your .htaccess? Maybe it’s something unrelated.

Hi, yes when I comment these:

# RewriteCond %{HTTP_HOST} !^www\.
# RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

I can login to the panel again.

What if you just redirect to http in the RewriteRule?

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Then I can’t access the site, the front-end any more.

But the panel works?

No, does not work either.

Where do you enforce https?

In config with c::set(‘ssl’, true);

Can you do the non-www www redirect in your DNS settings instead of in the .htaccess?

My co-worker is searching for that in the 1und1 settings, but it does not look good :frowning:

If you choose “Verwendungsart” and then “Weiterleitung” for the main domain, you should be able to redirect to www.yourdomain.de?

We can’t do that.

The problem seems:
I can’t login to panel on that url: https://www.mydomain.com/panel
I can login to panel on that url: https://mydomain.com/panel

My redirect rule says, it should only allow access when there is a www before.

This seems to work know:

RewriteCond %{HTTP_HOST} !^www.
RewriteCond %{REQUEST_URI} !^/panel/
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

1 Like

Interesting. But can you login at https://www.mydomain.com/panel if you disable the rewrite rule? Still trying to figure out if it’s the rewrite rule or something else. Because the rewrite rule shouldn’t be able to cause this.

I had the same issue with redirecting to https + www. also on an 1and1-host.
I couldn’t login to the panel on the production-environment.
After i set the url in the production-config, it works fine.

c::set('url', 'https://www.mydomain.com');

but i was wondering, why does the auto url not recognize the www?