Welcome back! In this short tutorial, we’ll be going to look at how to Forcefully Redirect Your Site on HTTPS from HTTP.
We have already covered how to issue a custom SSL for your domain in the previous tutorial. You can check that out, but sometimes it happens that when you open your site in a tab you still see a not secure warning/alert.
But when you look at your site’s management page in CyberPanel, it is telling you that <your-domain> has SSL from ZeroSSL or any other SSL certificate issuer just like in my case.
Then, you think of checking it another way around, just entering your domain on the URL bar
your-domain.com. And again you see the same Not Secure warning.
Ok, so what’s going on over here. You are getting a Not Secure warning on your site and your CyberPanel is showing that SSL is issued. Well, you need to do a simple step, just copy your domain from the URL bar and add ‘s’ after HTTP in the address bar after pasting it.
And then you’ll see the Lock icon indicating Your site is secure.
Alright, now you can have a moment of relief that your site is really running on HTTPS but here’s the thing that you need to know about. Whenever you create a new SSL certificate, you then also need to add the Rewrite rule which forces the site to run on HTTPS. We have written an article over Rewrite rules too. But don’t worry if you don’t want to get your hands dirty, CyberPanel has also taken care of it.
Forcefully Redirect Your Site on HTTPS
Just go to your site’s management page and scroll down to the Configurations category and click on Rewrite Rules. Then click on the dropdown to choose Force HTTP -> HTTPS to force the site to run on HTTPS and hit the Save Rewrite Rules button.
Then you need to restart your server if you are using OpenLiteSpeed. In the case of LiteSpeed Enterprise, you don’t even need to restart your server.
To restart the server, type the following command in your terminal:
sudo systemctl restart lsws