Hello.
I need help with url-rewriting in .htaccess.
So the issue is about different protocols: https and http. The main purpose of rewriting is to remove "www" from URL, but protocol should stay the same it was before.
For example, when I have URL like http://www.domain.com/request, it should be redirected to the http://domain.com/request. I resolve it with these rules:
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
But in case, when URL looks like https://www.domain.com/request it should be redirected to https://domain.com/request.
Unfortunately, the above rule will redirect to http regardless current protocol.
Thanks in advance.