Intermittently wrong hostnames in css references, why?

I’m an operator of an OJS installation (customized locally, based on version 2.4.6 I think, I don’t know the details).

We have an intermittent problem with “wrong” hostnames in css references, causing pages to be shown without styling, since we only have a SSL certificate for the “correct” hostname (not any aliases).

Example (right now shown without styling, might not apply when you read this): https://tidsskrift.dk/index.php/res_cogitans/issue/view/3169/showToc .

The hostname “tidsskrift.dk” shown in the above URL is correct, but page source shows:

...
<link rel="stylesheet" href="https://www.tidsskrift.dk/lib/pkp/styles/pkp.css" type="text/css" />
<link rel="stylesheet" href="https://www.tidsskrift.dk/lib/pkp/styles/common.css" type="text/css" />
…
var base_url = "https://www.tidsskrift.dk/index.php/res_cogitans/issue/view/3169/showToc";
...

The “wrong” hostname “www.tidsskrift.dk” is pointing to the same host as “tidsskrift.dk” (for historic reasons).
There are also some apache RewriteRules in play, e.g. all http requests are rewritten to https.

Our config.inc.php has the correct hostname in:

base_url = "https://tidsskrift.dk"

What can cause css references (and base_url) having a different hostname than the (correct) page URL hostname?
Any ideas are appreciated.

Thanks,
/ Peter

Solution in this case was to redirect all SSL requests to the correct host (tidsskrift.dk).

@peterny, your solution sounds correct. Alternately, you could add subject alternate names to the certificate. OJS will not itself automatically force a request to the specified base_url if the webserver allows multiple aliases.