Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Redirecting from http to https through .htaccess

Discussion in 'Security' started by Mrinmoy, Feb 9, 2019.

  1. Mrinmoy

    Mrinmoy Active Member

    Joined:
    Feb 2, 2019
    Messages:
    25
    Likes Received:
    5
    Trophy Points:
    3
    Location:
    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?
     
    #1 Mrinmoy, Feb 9, 2019
    Last edited by a moderator: Feb 9, 2019
  2. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    5,815
    Likes Received:
    444
    Trophy Points:
    233
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    Mrinmoy likes this.
  3. PatrickVeenstra

    PatrickVeenstra Well-Known Member

    Joined:
    Feb 12, 2012
    Messages:
    155
    Likes Received:
    3
    Trophy Points:
    68
    Location:
    Barcelona
    cPanel Access Level:
    Root Administrator
    MyBB: redirect if not https protocol
    Letsencrypt: redirect if default http port (=80, SSL/HTTPS is 403)
    CPanel: same as MyBB
     
  4. Mrinmoy

    Mrinmoy Active Member

    Joined:
    Feb 2, 2019
    Messages:
    25
    Likes Received:
    5
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Website Owner
  5. Mrinmoy

    Mrinmoy Active Member

    Joined:
    Feb 2, 2019
    Messages:
    25
    Likes Received:
    5
    Trophy Points:
    3
    Location:
    India
    cPanel Access Level:
    Website Owner
    I used the third code which was provided by cPanel. And it worked like a charm. Thanks.
     
    cPanelLauren likes this.
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice