If you are trying to serve-up different content for the same page request, depending on where the original page request comes from, then you may need to use a server-sided scripting language, such as PHP.
PHP holds the filename of the requesting file in the following variables:
You can examine the content in any of those variables, then return different body content in your html document, depending on the above variable content.
I might be wrong, but I do not think you can serve a different file, in place of the one requested by the browser, unless you use something like redirecting the page request.
I hope this answers your question.