AJAX或直接链接

What is the best way to handle Ajax vs. Full page requests with PHP ?

I mean if I click a button that calls Ajax function and loads necessary info into a div and changes the URL.

How do I make that link work if the user copy it and use later to reach the same page.

In some of the apps I separate it with a hash. Something like a router and my code goes something like this:

var preRoute = document.URL.split('#');
if(preRoute[1] != undefined) {
  //ajax call
} else {
  //default page
}

You could check the headers. jQuery for example will add the following key/value to the header: X-Requested-With: XMLHttpRequest for ajax calls. See also this question

Using: jquery pjax - https://github.com/defunkt/jquery-pjax

you can detect on server side if you get X-PJAX request header

And a great feature of this plugin is the history manipulation and ease of use.