Access control refers to any means of controlling access to any resource. This is separate from authentication and authorization.
If you wish to restrict access to portions of your site based on the
host address of your visitors, this is most easily done using
The
The
The usage of these directives is:
In the first form, address is a fully qualified domain name (or a partial domain name); you may provide multiple addresses or domain names, if desired.
In the second form, ip.address is an IP address, a partial IP address, a network/netmask pair, or a network/nnn CIDR specification. Either IPv4 or IPv6 addresses may be used.
See the mod_authz_host documentation for further examples of this syntax.
You can insert not
to negate a particular requirement.
Note, that since a not
is a negation of a value, it cannot
be used by itself to allow or deny a request, as not true
does not constitute false. Thus, to deny a visit using a negation,
the block must have one element that evaluates as true or false.
For example, if you have someone spamming your message
board, and you want to keep them out, you could do the
following:
Visitors coming from that address (10.252.46.165
)
will not be able to see the content covered by this directive. If,
instead, you have a machine name, rather than an IP address, you
can use that.
And, if you'd like to block access from an entire domain, you can specify just part of an address or domain name:
Use of the
Using the
Using the expr
syntax, this could also be written as:
Access control by User-Agent
is an unreliable technique,
since the User-Agent
header can be set to anything at all,
at the whim of the end user.
See the expressions document for a further discussion of what expression syntaxes and variables are available to you.
The [F]
For example, if you wish to block access to a resource between 8pm
and 7am, you can do this using
This will return a 403 Forbidden response for any request after 8pm or before 7am. This technique can be used for any criteria that you wish to check. You can also redirect, or otherwise rewrite these requests, if that approach is preferred.
The
The expression engine gives you a great deal of power to do a variety of things based on arbitrary server variables, and you should consult that document for more detail.
Also, you should read the
See also the Authentication and Authorization howto.