TL;DR: What alternatives to the last code sample on this page are there when trying to use relative links on pages included with PHP\'s include com
include
Looks like the best way to do this is removing $_SERVER['DOCUMENT_ROOT'] from __DIR__, as I mentioned in the original question.
$_SERVER['DOCUMENT_ROOT']
__DIR__
define('PROJECT_DIR', preg_replace('/^' . preg_quote($_SERVER['DOCUMENT_ROOT'], '/') . '/', '', __DIR__));
I think I'm just going to do it like that.