Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My server will be receiving a non-standard HTTP request named EmployeeID that I want to use to determine access rights to certain directories on the server. How can I store the value of the incoming non-standard HTTP request header so that it can be used in an If conditional using Apache directives?

After searching online for quite some time I came up with the following where I attempt to save the header to an environment variable using RewriteRule so that I could access the value of the variable later for the comparison. Unfortunately, I have only met frustration instead of success.

<Direcory "\Apache24\htdocs\usrs">
   RewriteEngine on
   RewriteRule .* - [E=EmployeeID:%{HTTP:EmployeeID}]
   <If "{Request_URI} != /%{EmployeeID}/">
      Deny from all
share|improve this question
up vote 0 down vote accepted

I think you want to use the SetEnvIf apache directive. Possibly:

SetEnvIf EmployeeId "^(.+)$" eid=$1
<Directory "\Apache24\htdocs\usrs">
    Order Deny,Allow
    Deny from all
    Allow from env=eid

Look at the Prevent "Image Theft" example, I think that might do something similar to what you need.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.