Mod rewrite and Apache processing phases

From RavenWiki
Jump to navigationJump to search

From the Apache mod_rewrite manual:

 Once a request comes in, and Apache has determined the appropriate server 
 (or virtual server), the rewrite engine starts the URL-to-filename translation, 
 processing the mod_rewrite directives from the  per-server configuration. A few 
 steps later, when the final data directories are found, the per-directory 
 configuration directives of mod_rewrite are triggered in the Fixup phase.

This is relavent to Raven because it means that if you want to create rewrite rules that refer to REMOTE_USER, or any other environment variables created by mod_ucam_webauth, those rewrite rules are must appear inside a <Directory> block or an .htaccess file. If they appear outside this they will be processed before mod_ucam_webauth runs and so before the variables are created. Alternatively, you can use the %{LA-U:REMOTE_USER} construct to cause mod_rewrite to generate a subrequest for the same URL and look at the value of REMOTE_USER that comes out of it.