Redirect HTTP to HTTPS

I was pleasantly surprised to see that CloudFlare had started providing a free SSL certificate to all its users, my site included.

I use a WordPress plugin to force HTTPS SSL on my pages, but the site is still accessible by HTTP, which leads to display issues. I want to force the native HTTP redirection to HTTPS in my .htaccess, but when I tried a redirect, I came across an infinite redirection loop.

How can I solve this?

2 Answers
2

I am answering this old question, as it still remains unanswered. Instead of using the plugin, you should use cPanel to redirect HTTP to HTTPS. It will help you to get rid of the infinite redirection loop issue. Follow these steps:

  1. Login to your cPanel account.
  2. Click on the File Manager.
  3. Ensure that public_html directory is being displayed. Scroll
    down and search for the .htaccess file. If you don’t see the file,
    head to Settings at the top-right corner. Then check the box to show
    hidden files for document root.
  4. Next, a pop up box will appear. Click on the Edit button to confirm
    encoding.
  5. A new tab will show up. It will contain the codes of .htaccess. Copy
    and pasted this code to .htaccess file:

    RewriteEngineOn
    RewriteCond%{HTTPS}off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
  6. Finally, save the changes.

You can find more information about these steps here.

If you see mixed content and face trouble with the redirection, you will have to use Really Simple SSL plugin. It will fix the issue completely.

Leave a Comment