Skip to content
SPECIAL DEAL: GET 10% OFF ANNUALLY OR 20% OFF BIENNIALLY!! Merry Christmas and a happy New Year from everyone at NuHosting

Forcing HTTPS And www Or Non-www

Choose one address for your website, for example https://yourdomain.co.uk, and send every visitor there. It is better for security and search engines.

Force HTTPS

In cPanel, open Domains and switch on Force HTTPS Redirect for your domain.

Choose www or non-www with .htaccess

Open public_html/.htaccess in File Manager and add one of these at the top.

Always without www:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]

Always with www:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

If you use WordPress, also set the same address in Settings → General.

Leave a comment

Your email address will not be published. Required fields are marked *