Of course, there is no perfect solution for this kind of thing, so it’s important to pay attention to the trade-offs of any solution you try to implement. The solution provided by Lord Eirias will generally stop people from loading your pages by clicking on links from pages outside your domain, but it won’t stop them from copying and pasting links into their browser’s address bar and hitting enter, or suggesting the same to other people.
If the goal want to prevent even that case, that will probably need some sort of login system. These are generally too complicated to describe in a forum post, but the logic is straightforward enough to work through. The downsides, of course, are complexity, and that it may not be a good/desirable idea to require users to get accounts.
Ultimately, the goal is to find the best tradeoff between complexity, user friendliness, and functionality. Curse this imperfect world