How to set up different documentroot for ip based requests, and different for domain based requests

view story

http://serverfault.com – My problem is simply that I have a domain, let's say example.com, and my server's ip address is e.g. I want to set up 2 different virtual hosts, so when user enters ip address ( in his browser, he will see content from here: /var/www/staging But if user will type example.com, he will see content from here: /var/www I think it's possible but I was playing around with it and couldn't make it work. Also I don't want to make simple redirection. I know I can, but I need both of my apps (live & staging) working in root on the same server. I can't buy second domain, a (HowTos)