What we will Cover in this Post:
Need Help?

We're always here for you. Submit a Ticket.

Contact Us

How to Redirect non-www to www with SSL/HTTPS?

Introduction

It's 2020 and SSL (HTTPS) is Crucial. Also, any Website Owner needs to assure their Visitor's Connection is Secure. It's a fact that Google algorithm for sites with SSL will Improve Ranking for those sites.

You can Redirect All of the Requests for yourdomain.com Domain to www.yourdomain.com by Modifying your Website's .htaccess File so all Traffic goes via HTTPS.

You need to add the following lines at the beginning of the .htaccess file in order to Setup that Redirection:

# ----------------------------------------------------------------------
# REDIRECT NON-WWW TO WWW
# ----------------------------------------------------------------------
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]

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

You can edit the .htaccess File using the File Manager in cPanel or via FTP.

From now on, when someone access http://yourdomain.com/ the visitor will be Redirected to https://www.yourdomain.com/.