1. Home
  2. Backup, Security & Performance
  3. SSL & Signing Certificates
  4. How to redirect http to https in cPanel and Plesk
  1. Home
  2. Backup, Security & Performance
  3. SSL & Signing Certificates
  4. How to redirect http to https in cPanel and Plesk

How to redirect http to https in cPanel and Plesk

How to redirect http to https

  1. HTTPS Redirection in cPanel.

Most of the shared hosting provider offers cPanel and an option to modify .htaccess where you can enter the following code to start the redirection.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

 Note: if you already have “RewriteEngine On” in your existing .htaccess file then you don’t need to duplicate it.

  • HTTP to HTTPS automatically in cPanel 

If you have a secure socket layer certificate (SSL) on your website, you can automatically redirect visitors to the secured (HTTPS) version of your site for a secure connection. Name.com hosting uses cPanel and there is a simple tool in cPanel that will help you accomplish this.

  • Log into your cPanel
  • In the Domains section, click the Domains icon.

 

 

 

 

  • This will open a page where you can toggle the HTTPS redirect on or off. We recommend leaving it on. If there is no option to enable HTTPS, it’s because that domain does not have SSL installed. First, make sure SSL is installed and the option will present itself.

 

 

 

 

 

 

2. HTTPS redirection in domain settings in Plesk (Plesk Onyx for Linux and Windows)

  • In Plesk, go to Domains> com > Hosting Settings.

 

 

 

 

 

 

  • Enable the setting Permanent SEO-safe 301 redirect from HTTP to HTTPSand select your certificate from the drop-down menu. Apply the changes.

Note: If the setting Permanent SEO-safe 301 redirect from HTTP to HTTPS is grayed out, please contact your service provider for assistance with permanent HTTPS redirection.

 

 

 

 

 

 

 

 

 

3. HTTPS Redirection in Apache.

  • Login to your Apache server and go to the path where it’s installed.
  • Go to conf folder and take a backup of httpd.conf file
  • Open httpd.conf using your vi editor (choose your favorite editor)
  • Ensure so the module is loaded.

LoadModule rewrite_module modules/mod_rewrite.so

If you see above line is commented then uncomment it

  • Add the following at the end of the file
  • RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
  • Restart Apache webserver to test it.
    A configured website should be able to redirect and accessible on https.

4. HTTPS Redirection in Nginx.

Login to Nginx web server and take a backup of nginx.conf or default.conf file (whatever file you are using for server directive)

  • Add the following in server directive

return 301 https://$server_name$request_uri;

  • Save the file and restart Nginx web server.
  • Restart Nginx to test the site.

5. HTTPS Redirection in Cloudflare.

If you are leveraging Cloudflare for performance and security, then having a website through HTTPS is very easy.

  • Login to Cloudflare >> select the site
  • Go to Crypto tab and scroll down to see the following.
  • Ensure it turned ON

 

 

 

 

 

There is another way, page rules.

  • Go to Page Rules
  • Click “Create Page Rule”
  • Enter the URL (put the asterisk, so redirection happens for all the URI)
  • Click “Add a Setting” and select “Always Use HTTPS” from the drop-down

 

 

 

 

 

 

 

 

 

  • Click “Save and Deploy”
Updated on April 15, 2020

Was this article helpful?