First off, you need to understand that there is no automatic relationship between 'example.com' and 'www.example.com'.
'www.example.com' is just a hostname within the 'example.com' domain, and is no different from any other hostname such as 'mail.example.com', 'foo.example.com', etc.
Now, by convention/convenience most people map 'example.com' and 'www.example.com' to the same IP address so that (lazy?) users can type the former into a browser and get to the web site, but that's not an automatic thing.
In this case, since it works externally but not internally, it sounds like you're using two different DNS servers (one for public users and a different one for private/LAN users) - which is a good idea. It just means that the internal DNS doesn't have the same configuration that maps 'example.com' to the address of your web server.
As for the fix - make sure that 'example.com.' has an A record that points to your web server's address.