This guy explains how AutoDiscover works in Exchange 2013.  I'm not going to re-invent this post, as it is well done already.  http://blogs.technet.com/b/rmilne/archive/2013/04/02/busting-the-set-autodiscovervirtualdirectory-myth.aspx

On a related note, here is a good post on changing the Virtual Directories in Exchange 2013:  http://msexchangeguru.com/2013/12/31/e20132007-urlsauth/