How to redirect www to nonwww with https

Hello Friends,

Im back with a tip for redirection using .htaccess redirect to nonwww with https. Hope this help someone.


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

RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]