Problem
Using .htaccess to force HTTPs on my WordPress site does not work
Tried solution
On my WordPress site I have the following .htaccess code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
But to force using HTTPs I’am trying to replace it with this code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} mydomain.dk [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mydomain.dk/$1 [R,L]
</IfModule>
Result
The website is no longer working (here is the website response):
This page isn’t working
www.mydomain.dk redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS
Questions
- Why can’t I force using HTTPs on my WordPress website?
- What can I do to make it work?
Best regards, Henning
2
Answers
Before trying the surggested solutions - I tried to change the URL in the Wordpress settings to HTTPS and now it works.
Thanks for taking the time to answer my question, I was just about to try the Really Simple SSL plugin.
If your web server is running Apache, you can redirect all HTTP traffic to HTTPS by returning to the default .htaccess configuration and than adding the following code to your .htaccess file.
This is also the recommended method for redirecting WordPress to Apache:
However, probably the easiest way to implement HTTPS on your WordPress site would be to install the following plugin:
https://wordpress.org/plugins/really-simple-ssl/