Nowadays, there’s really no excuse not to enable HTTPS on a website, even a small personal one. It’s free and simple. In fact, chances are that whatever host you’re using offers a simple option you can just turn on. In this article, we’ll see how to set this up in cPanel, which is commonly used in Linux/PHP/MySQL web hosting services.
Set up the Subdomain
If you haven’t already, create a subdomain. To do this:
- Locate the Subdomains service in cPanel.
- Enter a name for the subdomain.
- Enter a path to a folder to be used as the document root for the subdomain.
- Click the Create button.
Enable HTTPS on the Subdomain
New subdomains will by default run on HTTP, which is insecure. Enabling HTTPS requires an SSL or TLS certificate. To set this up:
- Locate the Let’s Encrypt™ SSL service in cPanel.
- Scroll towards the bottom of the page, and page through your subdomains until you locate the new one you want to apply HTTPS to.
- Click on the Issue action link next to it.
- Leave the settings as they are and click on the Issue button.
Enforce HTTPS on the Subdomain
Enabling HTTPS is only half good if people can still access the site insecurely over HTTP. It’s very easy to automatically redirect people from the HTTP endpoint to HTTPS. To do this:
- Locate the Domains service in cPanel.
- Locate the new subdomain, which may be on a different page.
- Turn on the switch in the Force HTTPS Redirect column.
- A success message should confirm that it’s been enabled.
Test the Subdomain
To make sure everything is set up correctly, use a browser to ensure that the website at your subdomain is secure.
- Wait a few seconds. The redirect you just enabled might not kick in right away.
- Use an incognito session in your browser. Otherwise, if you visited the subdomain before enabling the redirect, it’s possible that the browser might still show it as insecure.
- Access your domain with the URL starting with https://. Ensure that your browser displays the padlock icon and reports the connection as secure.
- Access your domain with the URL starting with http://. Once the page loads, ensure that you are now on https:// and that the browser displays the padlock icon and reports the connection as secure. Optionally, you can also open your browser’s dev tools, switch to the Network tab, and observe a 301 redirect request.
As you can see, it’s super easy to get HTTPS working on a subdomain in cPanel. Just enable HTTPS for the subdomain, force the HTTPS redirect, and you’re done.