The non-www to www redirect is most certainly being handled (later) by WordPress. Your existing redirect in .htaccess
is HTTP to HTTPS only, on the same host – which is actually the preferred (read: necessary) way if you have any plans to implement HSTS in the near future. So, this is not necessarily an “error”.
However, to avoid the double redirect, you can incorporate the non-www to www redirect into your existing .htaccess
rule. For example:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule .* https://www.example.com%{REQUEST_URI} [R=301,L]
If you particularly want a generic (any domain) solution, without hardcoding the domain, then you could do something like the following instead:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)\.?$ [NC]
RewriteRule .* https://www.%1%{REQUEST_URI} [R=301,L]
Where %1
is a backreference to the host name (less any www.
prefix) in the last matched CondPattern. Note, however, that without further modification this “generic” solution will also redirect subdomains.