Most of my team mates deploy project solutions to http://project.server.local/ which means all links used in the solution can be prefixed with “/” and everything is related to the root path and works just fine.
I’m different and use http://server.local/sites/project. And of course all links going to root for me will go to http://server.local instead of http://server.local/sites/project.
The solution, at least for global nav in master pages etc. is to make use of the variable _spPageContextInfo, blogged by numerous people. This object holds several properties about the current page/item you are viewing (see _spPageContextInfo is your new best friend by Sahil Malik for a complete property listing).
The code below is a sample of a hyperlink on an image to the front page of the current site collection.