Redirecting visitors to the homepage when they've requested a subpage is generally a bad idea because:
- Search engines will cease to index subpage content, resulting in big traffic drops.
- Users will struggle to find the information that brought them to the site in the first place.
However, if there's a very good reason to do so (and I can think of few), there are a couple of ways to redirect visitors to the homepage if they hit a subpage:
- Check for the existence of a cookie that's only set if they've visited the homepage.
- Check that the HTTP referrer belongs to the same domain.
Note that neither of these methods are foolproof, as both cookies and referrer information can be spoofed, but they will probably suffice for basic use.
A better alternative to the redirection system your client has asked for might be to detect that it's the first time a visitor's been to the site (with cookies), then show them a welcome message -- either inline with the HTML or as a subtle animated overlay -- prompting them to visit the homepage or read an FAQ to learn more, a bit like sites on the Stack Exchange network do. (Click for large view):