Question: Been wrestling with this for quite a while with no success. What I'm looking for is an .htaccess rule to ensure all requests:

1. always start with "www"
2. are always secure (https)

Of all the rules I tried, perhaps this was the closest:

```
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301]

```

This set of rules works great for:

* `http://www.example.com` > `https://www.example.com`
* `http://example.com` > `https://www.example.com`

Doesn't work for:

* `http://www.example.com/index.cfm?myquerystring`
* `http://example.com/index.cfm?myquerystring`

---

UPDATE:

The actual problem in my case is that for certain file extensions (.cfm,.cfml,.cfc) the request was being "handed off" to the application server before my rewrite rules were able to take affect. Thanks to all who responded.

Answer: 
Try this rule:

```
RewriteEngine On

RewriteCond %{SERVER_PORT} 80 [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L]

```
This should do the job:

```
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

```

Please, note that the .htaccess should be located in the website main folder.