Apache mod_auth and mod_rewrite Order

637 Views Asked by At

On this given server running Apache, mod_rewrite is executed prior to mod_auth. Normally not a critical issue except when you are trying to use the environmental variable, %{REMOTE_USER} - per .htaccess. In this scenario, it is undefined and unavailable to mod_rewrite. I have only seen this once before, and cannot recall the solution. It is related to server config (httpd.conf). Any ideas?

1

There are 1 best solutions below

5
On

You need to move your rules to your vhost/server config, and not inside of a <Directory> container. This makes it so the per-directory modules are applied first (e.g. mod_auth_*) before the per-server module (i.e. mod_rewrite).