GCS Amplitude
GCS Amplitude

Access Control

Access control refers to any means of controlling access to any resource. This is separate from authentication and authorization.

provides a variety of different ways to allow or deny access to resources. In conjunction with the Require

directives, these requirements may be combined in arbitrarily complex ways, to enforce whatever your access policy happens to be.RequireNone

directives, provided by Order

, are deprecated and will go away in a future version. You should avoid using them, and avoid outdated tutorials recommending their use. modaccesscompat

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 modauthzhost 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:

Require all granted Require not ip 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.

Require not hosthost.example.com

And, if you'd like to block access from an entire domain, you can specify just part of an address or domain name:

Require not ip 192.168.205 Require not host phishers.example.com moreidiots.example Require not host gov

Require All Denied

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.

RewriteEngine On RewriteCond %{TIMEHOUR} >=20 [OR] RewriteCond %{TIMEHOUR} <07 RewriteRule ^/fridge - [F]

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.

directive, added in 2.4, replaces many things that

has traditionally been used to do, and you should probably look there first before resorting to modrewrite.modrewrite

documentation for examples of combining multiple access requirements and specifying how they interact.modauthzcore

Modules | Directives | FAQ | Glossary | Sitemap

Apache HTTP Server Version 2.4

Access Control

Available Languages: en | fr

Related Modules and Directives

Access control can be done by several different modules. The most important of these are mod_authz_core and mod_authz_host. Also discussed in this document is access control using mod_rewrite.

Access control by host

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 mod_authz_host.

Access control by arbitrary variables

Using the , you can allow or deny access based on arbitrary environment variables or request header values. For example, to deny access based on user-agent (the browser type) you might do the following:

Access control with mod_rewrite

The [F] RewriteRule flag causes a 403 Forbidden response to be sent. Using this, you can deny access to a resource based on arbitrary criteria.

More information

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.