Redirecting from http to https through .htaccess

Mrinmoy

Active Member
Feb 2, 2019
38
5
8
India
cPanel Access Level
Website Owner
I am trying to do a 301 redirect. I am using letsencrypt SSL certificate here, so my redirect will be from http to https. My query is that my script provider (Mybb) has provided me with one code and letsencrypt has provided with another.

Mybb has provided me this one:
Code:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Letsencrypt has provided this one:
Code:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://mysitename.com/$1 [R=301,L]
And here in cPanel I have been suggested this one:
Code:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
I want to know what's difference between these. Are their function any different or all the same?

I am confused because mybb has already provided a default .htaccess file in which there are codes similar to these (which I have to assume those are their default redirects).

So, which code to use?
 
Last edited by a moderator:

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,263
313
Houston
  • Like
Reactions: Mrinmoy