Prevent direct access (from URL bar) to TXT file in page folder

Hello!

I have premium site and within its visible content there is a link to TXT file. By clicking on that link, txt file will not be downloaded, but instead it will be opened inside current user’s browser. Mentioned premium site is protected by Login plugin, so it can be viewed only by signed-in user, regardless of directly typing URL of that site in browser bar or by navigating to it from menu. AFAIK, this is not the case for media. Attribute protect_protected_page_media won’t “work” when visitor directly writes a URL of TXT file in browser bar. Is there any other attribute or plugin to prevent direct access? I heard .htaccess is a way-to-go on such scenarios. If anyone can, who used such approach, give me an advice on how to configure it or even share an example of .htaccess in one of his sites, I would really appreciate it.