The base element's "href" attribute is not required to be absolute,
so rewrite relative to the site URL if it is relative.
See:
* https://www.w3.org/TR/html51/document-metadata.html#the-base-element
* https://html.spec.whatwg.org/multipage/semantics.html#the-base-element
$base = $xpath->query('/html/head/base');
foreach ($base as $b) {
- $url = $b->getAttribute("href");
+ $url = rewrite_relative_url($url, $b->getAttribute("href"));
break;
}