[htaccess] Web access vs Server access

Is it possible to use an .htaccess file to restrict direct access to a file via its URL, but still allow the server to interact with it?

To see where I’m headed with this or why I’m asking: