Deny accessing the File in htaccess

I have a project one time that the file in WordPress directory is being index in Google so anyone can see the file I dont want to be public.

I used the code below to make sure no one can view the file.

Copy and paste this in your htaccess and rename to the file you don’t want to see by others.