It depends if you changed the owner of .htaccess previously to root and on your current file permissions.
Make sure .htaccess and other files are owned by www-data and that write permissions are set for the owner.
Check with ls -la /var/www/nextcloud
If any file or folder is listed with
-rw-r**** root root
then run chown -R www-data:www-data /var/www/nextcloud
If furthermore .htaccess only has read rights (r–r--r-- or r–r-----) then you also need to run: chmod 640 /var/www/nextcloud/.htaccess