W3-Video WEB Tutorials

w3-video.com is a Free eLearning Website with over 500 video tutorials on HTML5, XAMPP, .htaccess, Firefox, Notepad++

.htaccess Tutorial

Home HTML5 XAMPP .htaccess Firefox Notepad++


3. Deny directive | .htaccess Tutorial


Share it

The Deny directive allows you to deny access to your server or parts of your server (a specific directory and its subdirectories).

Syntax

1Deny 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:

Deny directive - Examples

1. Deny from all

All access denied
1Deny from all

2. Deny from host address (IP address)

Deny from full IP address
1Deny from 178.137.19.143
Deny from partial IP address
1Deny from 178
1Deny from 178.137
1Deny from 178.137.19
Deny from multiple IP addresses (full or partial IPs) space separated
1Deny from 178.137.19.143 94.153.9.66 195.242.218.133
Deny from netmask
1Deny from 178.137.0.0/255.255.0.0
Deny from CIDR
1Deny from 178.137.0.0/16
Deny from IPv6
1Deny from 2001:db8::a00:…
Deny from IPv6 subnet
1Deny from 2001:db8::a00:… /10

3. Deny from host name (domain) - not recommended! (requires HostnameLookups On)

Deny from fullDomainName
1Deny from 178-137-19-143-Ivv.broadband.kyivstar.net
Deny from partial Domain Name
1Deny from .net
Deny from multiple Domain Names
1Deny from domain1.com domain2.com de

4. Deny from env (environment variable, SetEnvIf)

Deny from env=variableNameYourChoice
1
2
SetEnvIf User-Agent "*.Trident.*$" noIE
Deny from env=noIE