Updated: 28 September 2026 · Applies to: cPanel & WHM 138 (Jupiter theme)
These rules send every visitor to one address, https://www.yourdomain.com, so search engines see a single version of your site (no duplicate http/https or www/non-www copies).
Add to .htaccess
Put this at the top of the .htaccess file in public_html:
RewriteEngine On
# http -> https, and add www in the same step
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,R=301]
To use the address without www instead:
RewriteEngine On
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]
Note: The domain needs a valid SSL certificate for both names. Set the same address in your application (for example WordPress Settings › General), and test in a private window.