1
votes

I want to force SSL for my site. It works with putting these 2 lines into .htaccess:

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://example.com/$1 [R,L]

But when I try to login, it gives me this error:

Invalid form token. Please reload this form and submit again.

Without those lines in .htaccess, it works fine, but SSL is not forced.

Is there any other way to force SSL and to be able to log in?

Thank you.

[SOLVED]
I've changed '[R,L]' to '[R=301,L]', logged out - and now SSL works!

  1. My .htaccess:


    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME}/index.html !-f
    RewriteCond %{REQUEST_FILENAME}/index.php !-f
    RewriteRule . index.php [L]

  2. Canonical URL is empty

  3. URS by SSL is 'https://example.com'
  4. Show only canonical URLs is ticked
Do you have a link where we can test it? We are using the same style, but it is working for us - Nicolai Krüger
Nicolai, sorry, a link to site, to login or to where? I had to comment out those 2 lines in .htaccess because I couldn't log in anymore - linuxoid
We are using RewriteCond %{HTTP_HOST} ^domain.com$ RewriteRule (.*) https://www.domain.com/$1 [R=301,L] Try that, who knows. Maybe it works... - Nicolai Krüger
Nevermind! I think I got it. Under System & Settings->SEO & Statistics->URLs and Redirection, have you entered Canonical URLs? - Nicolai Krüger
Yes, I did. I've updated my question. It fixed itself. - linuxoid