Modify .htaccess in Nextcloud-directory to redirect visitors from https://www to https:// (without www)?

Due to uniformity I want to redirect visitors from to (without www).

My question now is: Can I simply insert an additional command like…

# Redirect www to non-www for cloud-subdomain:
RewriteCond %{HTTP_HOST} ^www\.cloud\.example\.com$ [NC]
RewriteRule ^{REQUEST_URI} [R=301,L,NE]

… into the .htaccess-file from the Nextcloud-directory? Furthermore, where has this command to be placed in the file? Or doesn’t it matter?

Thanks a lot for your help! :wink:

I assume you can put it in just under the section which starts

RewriteEngine on

and you can probably use below

force https on all uses

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