I am currently trying to develop a small Apache module which needs to retrieve the request's document root (as defined in the server configuration).
I had a look at httpd.h
to see if I could find this information somewhere in the data structures (request_rec
, server_rec
) but I couldn't find anything like it.
Is it possible to retrieve the request's document root from an Apache module?
What you are looking for is in http_core.h:
AP_DECLARE(const char *) ap_document_root(request_rec *r);
BTW, there's a warning on its usage:
"Modules shouldn't be worried about the document root. If you need to call this function, then you should ask yourself "why". Modules should be more concerned with r->uri and r->filename." [source]