3. Deny directive | .htaccess Tutorial
The Deny directive allows you to deny access to your server or parts of your server (a specific directory and its subdirectories).
Syntax
1 | Deny from all|host|env=[!]env-variable [host|env=[!]env-variable] ... |
-
all
= all access denied to the server
host
= only specified host addresses (IPs), host names are denied
env
= access denied based on set environment variable
You can Deny access from:
- all
- IP
- host name (not recommended)
- environment variable »SetEnvIf
Deny directive - Examples
1. Deny from all
All access denied1 | Deny from all
|
2. Deny from host address (IP address)
Deny from full IP address 1 | Deny from 178.137.19.143
|
Deny from partial IP address1 | Deny from 178
|
1 | Deny from 178.137
|
1 | Deny from 178.137.19
|
Deny from multiple IP addresses (full or partial IPs) space separated1 | Deny from 178.137.19.143 94.153.9.66 195.242.218.133
|
Deny from netmask 1 | Deny from 178.137.0.0/255.255.0.0
|
Deny from CIDR 1 | Deny from 178.137.0.0/16
|
Deny from IPv6 1 | Deny from 2001:db8::a00:…
|
Deny from IPv6 subnet1 | Deny from 2001:db8::a00:… /10
|
3. Deny from host name (domain) - not recommended! (requires HostnameLookups On)
Deny from fullDomainName 1 | Deny from 178-137-19-143-Ivv.broadband.kyivstar.net
|
Deny from partial Domain Name1 | Deny from .net
|
Deny from multiple Domain Names1 | Deny from domain1.com domain2.com de
|
4. Deny from env (environment variable, SetEnvIf)
Deny from env=variableNameYourChoice1 2
| SetEnvIf User-Agent "*.Trident.*$" noIE Deny from env=noIE |