apache - Meaning of apache2 CONTEXT_DOCUMENT_ROOT and CONTEXT_PREFIX? -


how apache2 (2.4) cgi environment variables context_document_root , context_prefix defined?

from experimentation, i've determined following:

  • context_document_root appears full local path original request when directoryindex or errordocument call cgi script.

  • context_prefix appears original request_uri, sans query part, when directoryindex or errordocument have called cgi script. (in these cases, request_uri set uri of cgi script, rather original.)

however, can't seem find official documentation apache on these variables. here have link such documentation, or more authoritative knowledge share?

context_prefix , context_document_root tell how apache used alias directive (or similar feature - mod_userdir) translate url path file system path. file system path end pointing the file served or cgi script run.

so, if apache translates url:

    http://host/_context_prefix/path/file 

to file system path:

    /_context_document_root/path/file 

it implies there alias (or scriptalias or similar mechanism such mod_userdir) following:

    alias /_context_prefix /_context_document_root 

the alias directive saves /_content_prefix in ${context_prefix} , /_context_document_root saved in ${context_document_root}.

here 1 example of using it. in <directory> context rewriterule translates path name relative directory absolute url path, or absolute file name (which must exist). if wanted translate url's ended in .htm .php, have write this:

    <directory "/_context_docment_root">         <filesmatch "*.htm">             rewriteengine on             rewriterule (.*)[.]html$ /_context_document_root/$1.php         </filesmatch>     </directory> 

now can write without repeating /_context_document_root, perhaps more importantly file not have exist because rewriting url path:

    <directory "/_context_docment_root">         <filesmatch *.htm>             rewriteengine on             rewriterule (.*)[.].* ${context_prefix}/$1.php         </filesmatch>     </directory> 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

jquery - Keeping Kendo Datepicker in min/max range -