you can use the following macro in your template:
{.if |{.pos|mydomain.com|{.header|host.}.}|{: .... do something or set a variable you use later .... :}.}
This might be useful, if you want to generate different pages depending what url is used to access your server, for example if you have more than one domain names, or if you want to distingush users from wan or from lan.
But if you publish or mail a full valid downloadlink (for example: http: // mydomain.com/topic/filename.ext) then the download request will be executed directly and the only way to avoid access is protecting your server with user access rights.