.htaccess redirects disappeared after re-saving permalinks

Hello and sorry for these newbie questions… I want my wordpress website to load with https+non-www and without traling slashes. I put the following code in .htaccess file:

<IfModule mod_rewrite.c>  RewriteEngine On  # Remove trailing slash from non-filepath urls  RewriteCond %{REQUEST_URI} /(.+)/$    RewriteCond %{REQUEST_FILENAME} !-d  RewriteRule ^ https://domain.com/%1 [R=301,L]  # Force HTTPS and remove WWW  RewriteCond %{HTTP_HOST} ^www\.(.*)$   [OR,NC]  RewriteCond %{https} off    RewriteRule ^(.*)$   https://domain.com/$  1 [R=301,L] </IfModule> 
  1. These rules work fine but I can’t remove multiple slashes after domain. The website loads: "https://domain.com/////" and I want it to redirect to "https://domain.com"

  2. Also, these rules work if they are only in the beginning of the htaccess file and when I re-save the permalinks the rules disappear…

Could you help me, please