How can I redirect my domain to show https://www in the URL bar?

Let's say you have the domain ethernetservers.com and wish to have it automatically redirect to https://www.ethernetservers.com (note the https:// and www.) when visitors go to ethernetservers.com, this can be easily achieved using htaccess!

Create (or modify) a file called ".htaccess" in your domain's root directory, and add the following:

RewriteEngine On
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
# [NC] is a case-insensitive match
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

That's it, you're done! 

Please note, you may need to clear your browser cache (or try another web browser) to see the change take effect. 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Full list of features

Below is a full list of all the options that will be available within your cPanel account:...

What name servers should I use for my website?

The name servers vary depending on the server that your account is on. Please search your email...

My site is displaying errors, help!

Errors can appear on websites for a number of reasons. Usually, these issues are quick to...

My site is being slow, what should I do?

If your website is being slow, we suggest doing the following: – Try to access your domain...

How do I secure my site?

These are some of the things we recommend you do to help secure your website.   1) Keep...