replaceState support; improved relative url handling