Introduction
The server's hostname can be secured when accessing cPanel related services like /webmail, /cpanel, /whm links just to mention a few examples.
However, there are cases where a custom redirection would be needed to ensure redirection for the server's hostname itself, for example, host.example.com without any specific services.
This can be easily done by adding a redirect to the following file:
/var/www/html/.htaccess
Procedure
- Open or create the /var/www/html/.htaccess file with your favorite text editor.
- Add a redirection block similar to the following:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^host.example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://host.example.com/$1 [R,L] - Make sure to replace "host.example.com" with the actual server's hostname.