Раздел 6. Guides, Tutorials, and HowTos RU EN Пункт 50. Access Control Access control refers to any means of controlling access to any resource. This is separate from authentication and authorization. Related Modules and DirectivesAccess control can be done by several different modules. The most
important of these are 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
The
The The usage of these directives is: Require host address Require ip ip.address 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 <RequireAll> Require all granted Require not ip 10.252.46.165 </RequireAll> Visitors coming from that address ( Require not host host.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 Use of the Access control by arbitrary variablesUsing the <If "%{HTTP_USER_AGENT} == 'BadBot'"> Require all denied </If> Using the Require expr %{HTTP_USER_AGENT} != 'BadBot' Warning:Access control by See the expressions document for a further discussion of what expression syntaxes and variables are available to you. Access control with mod_rewriteThe For example, if you wish to block access to a resource between 8pm
and 7am, you can do this using RewriteEngine On RewriteCond "%{TIME_HOUR}" ">=20" [OR] RewriteCond "%{TIME_HOUR}" "<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. The More informationThe 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. |
![]() |