Pages

How to force redirect HTTP to HTTPS?

To redirect all traffic from HTTP to HTTPS , you have to create a .htaccess file under public_html directory and put some line of codes within the file.

You can do that easily via cPanel File Manager.
  • First of all Log into your cPanel and search for File Manager under FILES section.

  • File Manager

  • In the File Manager window that opens, click the Settings button at the top right of the page.

  • Settings

  • In the Preferences panel that opens, ensure Show Hidden Files (dotfiles) is checked and click Save.

  • Hidden Files

  • Now use the folder tree in the left sidebar to navigate to the root of your website. Check to see if a file named .htaccess already exists. It can be created by default when you install popular CMS packages like WordPress, Drupal or other web apps.

  • .htaccess

  • If you do not see a .htaccess file, at the top of the page, click + File. In the panel that opens, under New File Name, enter .htaccess and click Create New File.

  • create .htaccess file

  • Otherwise, highlight the .htaccess file with a left-click and, Right click, select Edit. If you’re asked to confirm encoding, click Edit once again.

  • edit htaccess file

  • The cPanel text editor will now open. If you are creating a new .htaccess file, you’ll see a blank page. However, existing files may already include a set of rules,

    Enter the following code in your .htaccess file:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  • Click Save Changes to complete the redirection.

0 comments:

Post a Comment