Searched the web and found few variations of the RewriteCond & RewriteRule to 301 redirect www.cloud.domain.com/* to http(s)://cloud.domain.com/* (not changing the path) but I am stuck on every try and the redirects dont work - “www.” opens as before.
Do anybody have an idea if something can prevent the redirect of happening? How to fix the issue if the problem is not in this particular module of .htaccess?
here is my code snippet:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} DavClnt
RewriteRule ^$ /remote.php/webdav/ [L,R=302]
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^.well-known/carddav /remote.php/dav/ [R=301,L]
RewriteRule ^.well-known/caldav /remote.php/dav/ [R=301,L]
RewriteRule ^remote/(.) remote.php [QSA,L]
RewriteRule ^(?:build|tests|config|lib|3rdparty|templates)/. - [R=404,L]
RewriteRule ^.well-known/(?!acme-challenge|pki-validation) /index.php [QSA,L]
RewriteRule ^(?:.(?!well-known)|autotest|occ|issue|indie|db_|console).* - [R=404,L]
RewriteCond %{HTTP_HOST} ^staticIP$
RewriteRule ^(.*)$ https://cloud.domain.com/$1 [L,R=301]
# Redirect to non-www
RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>
tried few variations of the last 2 rows (even changing their place in the begining) and this doesn’t seem to help, so I will be thankful for code corrections, but I don’t believe this will resolve the issue.
Thank you in advance!