Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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
   </If>
</Directory">
share|improve this question

1 Answer 1

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
</Directory>

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

share|improve this answer

Your Answer

 
discard

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.