I have developed plenty of sites on EE2 and used the following htaccess code to force https:// with no issues.
Now in EE3 (to which I am very green in) when I use the force https:// code it creates an infinite loop.
It is as if something in the EE CMS is forcing the https:// to go http:// thus creating the loop.
I have all my path settings in EE3 set to https:// so I don’t know what could be causing it.
Below is the htaccess code I am using.
Any ideas?
Thanks.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Canonical www
RewriteCond %{HTTP_HOST} !www.example.com$ [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/x74fg3xvsp94F334/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
ExpressionEngine doesn’t perform any redirects on its own, so it’s likely server config related. I think you mean RewriteCond %{HTTPS} !on
instead of RewriteCond %{HTTPS} !=on
? Otherwise nothing gets my attention, except that if your web server is not setting the HTTPS
environment variable at all, you’d be constantly redirecting.
I often use these two tools to help me nail down .htaccess woes:
http://www.redirect-checker.org - so I can see the redirects that are occurring, which often give a clue where to look
and
http://htaccess.madewithlove.be - to help me verify that my .htaccess is doing what I think it’s doing.
Hi Derek.
Thanks for clarifying that EE3 doesn’t do anything as far as redirecting.
It made me look deeper.
I did not develop this site originally so started to pick apart the templates.
The following was in the header, which after removing solved the issue.
[script]
if ([removed].protocol == "https:") {
[removed] = document.URL.replace("https://", "http://");
}
[/script]
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.