Redirect https://www to https://non www

Hello, I’m creating a wordpress multisite with subdomains and a letsencrypt wildcard ssl cert, everything is working fine except for this…
I’m having problems with htaccess redirection.
I’m using this code

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.)$ [NC]
RewriteRule ^(.
)$ https://%1/$1 [R=301,L]

in htaccess to redirect http://, http://www. and www. to https://non www and it is working fine. For example it will redirect to and to
But if i try to open it will not redirect to https://non www creating an ssl cert error.
What I’m doing wrong?

Hello and thanks in advance for your help. I’m looking to redirect to
I did achieve success with http to https, but no luck trying to redirect https://www to https non www
Any help?

My reasonr for this is that https://www.* is breaking ssl