How to force use HTTPS and WWW in .htaccess file

If you have purchase SSL certificate for your website or want to use our SSL certificate for free.
You have to login into your website via ftp connection using software like filezilla, winscp.

Create a file name .htaccess (starting with dot and end on ss) and just paste the following code and change it to your domain name or tld in the file and click save.

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]

  • How to force use HTTPS, htaccess
  • 5 Users Found This Useful
Was this answer helpful?

Related Articles

How to create email account?

Log in to cpanel using your username and your cpanel password at http://yourdomain.com/cpanel,...

How to change webmail password from cPanel?

Log in to cPanel using your username and your cPanel password at http://yourdomain.com/cpanel,...

How to add addon domain in cPanel?

Log in to cPanel using your username and your cPanel password at http://yourdomain.com/cpanel,...

How to change cPanel password?

Log in to cPanel using your username and your cPanel password at http://yourdomain.com/cpanel,...

How to change PHP version from cPanel ?

Log in to cPanel using your username and your cPanel password at http://yourdomain.com/cpanel,...