I'm not 100% sure what problem you're trying to address with this, but you may just have to change the
<base> tag for the page, which would have the effect of changing the base location for all of your relative URL's in the HTML itself:
<base
href='http://www.example.com'
src='http://www.example.com'
>