How to password protect a folder/file on nextcloud

Hello, how do I password protect a file or folder. I would like to password protect a file or folder, I want it to be seen, but not accessible except if you have a password.

Zip the folder/file using 7zip with a password…

Use the solution from @henry in nextcloud.
Perhaps you also can protect some files (e.g. PDF) directly with password.

If you have a normal webserver you can protect folders with htaccess / htpasswd
Search “apache2 htaccess”.

You can not use this feature inside your nextcloud directory.
You can configure htaccess directly in the directory (.htaccess) or in apache2 configuration.
Nextcloud uses .htaccess for a lot of features (e.g. rewrites). Please do not edit or add .htaccess-files in nextcloud directory.