Sudec
Sudec

Reputation: 124

forcing HTTPS with .htaccess resulting in redirect loop

I'm trying to force all users coming to my page access it through https. I have googled a lot and found tons (mostly the same) .htaccess solutions but with all of them I get the "This webpage has a redirect loop Reload" in chrome and similar in firefox.

This is what I have currently in my .htaccess file.

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

link to site.

Can anyone advise what the issue might be because I have no idea.

Thanks

Upvotes: 1

Views: 1344

Answers (1)

anubhava
anubhava

Reputation: 785306

Try this rule:

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteCond %{SERVER_PORT} =80
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,NE,L]

Just make sure this is very first rule in your .htaccess file.

Upvotes: 3

Related Questions