We’re rewarding the question askers & reputations are being recalculated! Read more.
1 of 3

cPanel is notoriously bad for managing redirects. (I didn't think you could create HTTP to HTTPS redirects using cPanel alone?)

I do not know if this is possible...

Probably not from cPanel. But this is relatively straightforward in .htaccess (by directly editing the file itself). To be honest, if something of this nature is not possible in .htaccess then it's probably not something you should be doing in the first place.

If you simply want to redirect from HTTP to HTTPS on the same hostname then all you need is something like:

RewriteEngine On

# Redirect HTTP to HTTPS on the same host
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

The HTTP_HOST server variable contains the hostname from the request. eg. example1.com, example2.com, www.example1.com. Note that this alone does not canonicalise the www subdomain.

This is also a 302 (temporary) redirect (the same as simply specifying the R flag by itself). Change to a 301 (permanent) only when you are sure it's working OK. (301s are cached hard by the browser so can make testing problematic.)

To canonicalise the www subdomain and redirect non-www to www then add an additional directive:

RewriteEngine On

# Redirect non-www to www (and HTTPS) on the same domain
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

# Redirect HTTP to HTTPS on the same host
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

This does assume that you don't have any other subdomains (other than www) on these domains.

No need to repeat RewriteEngine more than once.