You need to have a SSL certificate in place before using the shown codes. Place one or the other in your cPanel public_html/.htacces file. Important: any .htaccess file must start with a dot and the chmod (pernmissions) are ALWAYS set at 644
If the .htaccess file does not have the "RewriteEngine on" in the file, uncomment by removing the hashtag. This only needs to appear once in the .htaccess file as it will cover all other Rewrites present and future. Replace example dot com with your domain name
This forces all http pages to No WWW https
This forces all http pages to WWW https
If the .htaccess file does not have the "RewriteEngine on" in the file, uncomment by removing the hashtag. This only needs to appear once in the .htaccess file as it will cover all other Rewrites present and future. Replace example dot com with your domain name
This forces all http pages to No WWW https
Code:
#RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
This forces all http pages to WWW https
Code:
#RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]