Force Http to Https

I have used Lets Script Free SSL on my DreamPress 2 hosting. My .httaccess file contains the below code to redirect all http request to https. but when I try to access my site it says too many redirects. Can you guys help?

BEGIN WordPress

RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

END WordPress

This is what I use:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$$1 [L,R=301]

Change “” to your domain. It just kicks any request to HTTP over to HTTPS for the same path at your domain.

I had the same exact problem and was told by support that for such accounts (DreamPress 2 with Let’s Encrypt) you need to use this:

RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

This should solve the problem; it did for me!

I just have to say that the code above is for 302 temporary redirect, to get a 301 permanent redirect just replace the code in the last brackets to be [L,R=301]