Yes, with .htaccess in case of Apache Webserver. You must deny all and allow your host only.
http://httpd.apache.org/docs/2.2/howto/access.html
Respect that any self-calling method on your webserver is a try that impacts your server-performance and reduce the possible max client calls on that engine. In my point of view such tasks are worst practice ( in a lot of cases ).