Redirect my WordPress website to HTTPS for cPanel hosting

After your SSL certificate is installed on your cPanel (Linux) hosting account, there are some modifications you'll need to make to your .htaccess file to automatically redirect your visitors to an HTTPS version of your website.

 Note: These instructions don't apply to Managed WordPress accounts with an SSL certificate. The HTTPS redirect is automatically enabled after the SSL certificate install finishes on a Managed WordPress account.

    1. Log into your WordPress Dashboard.
    2. Hover over Settings on the left navigation panel, then click General.
    3. Locate the following fields on the new page:
      • WordPress Address (URL)
      • Site Address (URL)
    4. In each field, update your URLs to include https instead of http.
      • For example, http://coolexample.com would become https://coolexample.com.
    5. Scroll down to the bottom of the page and click Save Changes.
    6. Open your current .htaccess file in the /public_html/ folder with the cPanel file manager for editing.
    7. Insert the following code at the top of your .htaccess file:
# BEGIN GD-SSL
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_USER_AGENT} ^(.+)$
RewriteCond %{SERVER_NAME} ^coolexample\.com$ [OR]
RewriteCond %{SERVER_NAME} ^www\.coolexample\.com$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
Header add Strict-Transport-Security "max-age=300"
</IfModule>
# END GD-SSL

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
  1. Click Save Changes at the top-right corner of the screen.
  • cpanel, wordpress, redirect, linux, htaccess
  • 3 Users Found This Useful
Was this answer helpful?

Related Articles

How to Install cPanel and WHM in CentOS 7

Installation of cPanel in CentOS 7 1. Ensure that your server has a standard hostname (FQDN or...

How to install WordPress through cPanel

Install WordPress with simple steps We link to the Magic Streams website and then go to the...

Redirect my site to HTTPS in cPanel / Linux

If you have a secure SSL on your site, you can automatically redirect visitors to the secure...

How to Update cPanel License Key / Run License Script

To run the cPanel License Key update script (perhaps if you've upgraded from a trial license, or...

How to Install WHM/cPanel on RHEL or CentOS VPS

To install cPanel, run the following commands while logged in to your VPS as the root user: # cd...