Fun with .htaccess #3: Access Restrictions
As with custom error pages and passwords, imposing access restrictions requires that you use place a file called .htaccess in the folder to which you want to limit access. If you've stuff in it already, (e.g. for passwords) put this at the very bottom, otherwise just put it in on it's own.
order deny,allow deny from all allow from .ucc.ie
The first line specifies that denial is to be the norm. The second specifies that access should be forbidden in all domains. The last line makes an exception to this rule. It specifies that access should be allowed from any machine in the ucc.ie network. Note that the domain[1] is prefixed by a period ('.'), this is very important. You can add more than one domain if you want. The following example allows access from UCD and UL.
.htaccess
order deny,allow deny from all allow from .ucc.ie .ul.ie .ucd.ie
That's it basically. If you've specified passwords, error documents and access contraints, put the password statements first, then the error document statements, and put the lines relating to access constraints at the bottom.
- A domain is the name of the network a computer is on. A network address for a computer is composed of two parts, the computer's name and the network's name. For example our webserver is called "www" and it's domain is "ucc.ie" so it's full network name is www.ucc.ie. Thus the full network name of any machine on the UCC network is going to end with ucc.ie. This is how the webserver restricts access.