Apache: Http to Https & no-www to www

If you want to force the visitors use Https instead of Http you need to modify/create the file .htaccess located in the root directory:
Open the file .htaccess and add the following lines:

  • HTTP to HTTPS
  • RewriteEngine On
  • RewriteCond %{HTTPS} off
  • RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L] 
  • No-www to www
  • RewriteEngine On
  • RewriteCond %{HTTP_HOST} ^domain.com
  • RewriteRule (.*) https://www.domain.com/$1 [R=301,L]