I've been using relative paths in SharePoint masterpages the wrong way. Let's see an example of how I used to do it, with a link to the homepage and an image for the logo.
<a href="http://www.broculos.net/en" class="logo"> <img src="/Style Library/CustomStyle/Images/logo.png" alt="" /> </a>
This will work like a charm if your site collection's home URL is the same as the root of the URL, for example: http://www.example.sp2010.dev/.
If this is not the case, as in URLs like this one: http://www.example.sp2010.dev/sites/anothersitecolection/ , my logo will still link to http://www.example.sp2010.dev/ and the image source will be also pointing to the wrong library. Here's how you should do it, and this will always work correctly:
<a href='<SharePoint:EncodedLiteral runat="server" text="<%$SPUrl:~SiteCollection/%>" EncodeMethod="HtmlEncode"/>' class="logo"> <img src='<SharePoint:EncodedLiteral runat="server" text="<%$SPUrl:~SiteCollection/Style Library/CustomStyle/Images/logo.png%>" EncodeMethod="HtmlEncode"/>' alt="" /> </a>