protected function rewriteResponse(Request $request, Response $response)
    {
        // for debugging purposes. Might need to be configurable.
        if ($request->query->get('__disable_aliasing')) {
            return;
        }
        if (preg_match('!^/admin/!', $request->getRequestUri())) {
            // don't bother here.
            return;
        }

        if ($response->getContent()) {
            $contentType = current(explode(';', $response->headers->get('content-type', 'text/html')));
            $response->setContent(
                $this->aliasing->mapContent(
                    $contentType,
                    UrlMapperInterface::MODE_INTERNAL_TO_PUBLIC,
                    $response->getContent(),
                    [$request->getHttpHost()]
                )
            );
        }
    }