How to add a rule that it applied for the domains of the 3rd level?

There is a rule to redirect http and https www to non-www, but it does not work for domains of the 3rd level, and Supplement correctly I don't know.

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} ^www\.(.+)$
RewriteRule (.*) https://%1/$1 [R=301,L]
April 4th 20 at 13:26
1 answer
April 4th 20 at 13:28
RewriteCond %{HTTP_HOST} ^www\.(.+)\.(.+)$
RewriteRule (.*) https://%1/$1 [R=301,L]
it will be for only the third level

You can even try to integrate
RewriteCond %{HTTP_HOST} ^www(\.(.+)){1,2}$
RewriteRule (.*) https://%1/$1 [R=301,L]
But judging by the regular season there, and so was supposed to work.

Find more questions by tags Apachehtaccess