*Ahí - When "there" is either near the person being talked to, or within a relatively nearby location to both the speaker and the listener.
Examples:
"¿Qué tienes ahí?" - "What do you have there?"
"El libro está ahí, en ese escritorio"
**Allí - When "there" is relatively far away (farther than "ahí"), but still visible.
Example:
"Gloria vive allí, en aquella casa" - "Gloria lives over there, in that house"
Hope that helped :)