Forum Moderators: phranque
Here is what I want to do in English:
I am webmaster of an Air Force site. We are trying to move our users away from the site I maintain and encouraging them to use our new Portal. I'd like to restrict users from viewing my web site unless they are coming from an Air Force Portal URL. At the same time, I do not want to closeout access to those users outside the Air Force who need access but cannot get access through the Air Force Portal. Hope this makes sense.
So in English it would be:
Allow "https://www.afportal.mil" (referring URL)
Allow army.mil (domain)
Allow navy.mil (domain)
Allow .gov (domain)
Deny af.mil AND redirect to "https://www.afportal.mil"
Deny .com AND redirect to "http://www.afpublic.com/"
Could you help me to translate this into real code PLEASE!?
Since then I've found some code similar to what I am trying to do. I've tested out allowing from http_referer but when I test this, it denies access.
SetEnvIf Referer "^https://www7\.my\.af\.mil" allowit
<Limit GET>
Order deny,Allow
deny from all
Allow from allowit
</Limit>
The url I am testing from is [www7.my.af.mil...]
THANKS!
deny should start with a capital D. Also, while I was looking for more info about the Limit directive, I found this in the Apache documentation [httpd.apache.org]:
A <LimitExcept> section should always be used in preference to a <Limit> section when restricting access, since a <LimitExcept> section provides protection against arbitrary methods.
In the meantime, I changed it to this (something else I found on the web) and it worked:
SetEnvIfNoCase Referer ".my\.af\.mil" allowit
<Files *>
order deny,allow
deny from af.mil
allow from env=allowit
allow from army.mil
allow from navy.mil
allow from .gov
</Files>
I dont understand a couple things...
1) what the difference is between <Files *> and <Limit>?
2) what does the "^" character do?
3) in what order do the commands get executed? I figured that if I put "deny from af.mil domain" first, it would deny anyone coming from ".my.af.mil" url as well, but it didnt.
So I am a little confused. I guess I will research this further.
Thanks.
Apache HTTP Server 2.0 directive quick reference [httpd.apache.org]
Regular expressions [etext.lib.virginia.edu]