Skip to main content
1 of 4
Ilmari Karonen
  • 9.1k
  • 1
  • 25
  • 41

For your first two rewrites (non-www → www, http → https), the following rule should work:

RewriteEngine On

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !=www.example.com [NC]
RewriteRule ^(.*) https://www.example.com/$1 [NS,L,R=permanent]

Just replace www.example.com with the actual canonical hostname of your site.

As for your third point, there's no need to add or remove trailing slashes from URLs with an empty path, since such URLs are treated as canonically equivalent by all standards-conforming HTTP clients (including browsers and search engines).

Ilmari Karonen
  • 9.1k
  • 1
  • 25
  • 41