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++


2. Allow directive | .htaccess Tutorial


Share it


The Allow directive controls who is allowed to access your server or parts of your server (a specific folder/directory and its subfolders/subdirectories).

Syntax

1Allow from all|host|env=[!]env-variable [host|env=[!]env-variable] ...
  • all = everyone has access to the server
    host = only specified host addresses (IPs), host names have access
    env = access allowed based on set environment variable


You can Allow access from:

  1. all
  2. IP
  3. host name (not recommended)
  4. environment variable »SetEnvIf

Warning

The Allow directive alone does not imply deny: e.g. allowing from an IP does not imply deny from all others.
If you want to restrict the access to your server, the Deny directive is required or, for a better control, Order directive with AllowDeny directives.



Allow directive - Examples

1. Allow from all

Allow everybody access
1Allow from all

2. Allow from host address (IP address)

Allow from full IP address (Googlebot)
1Allow from 66.249.79.76
Allow from partial IP address
1Allow from 66
1Allow from 66.249
1Allow from 66.249.79
Allow from multiple IP addresses (full or partial IPs) space separated (Googlebot msnbot)
1Allow from 66.249.79.76 207.46.13.49
Allow from netmask
1Allow from 66.249.64.0/255.255.224.0
Allow from CIDR
1Allow from 66.249.64.0/19
Allow from IPv6
1Allow from 2001:db8::a00:…
Allow from IPv6 subnet
1Allow from 2001:db8::a00:… /10

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

Allow from full Domain Name
1Allow from crawl-66-249-79-76.googlebot.com
Allow from partial Domain Name
1Allow from .com
Allow from multiple Domain Names
1Allow from domain1.com domain2.com .fr de

4. Allow from env (environment variable, SetEnvIf)

Allow from env=variableNameYourChoice
1
2
SetEnvIf User-Agent "*.Trident.*$" okIE
Allow from env=okIE

Video demonstration Allow directive | .htaccess Tutorial

Allow directive in .htaccess, Tutorial

min video details
00:01 Allow directive .htaccess Apache, Tutorial
00:04 The Allow directive controls who is allowed to access your server or parts of your server
00:08 Syntax Allow directive
00:10 'Allow' directive
00:12 'from' argument
00:00 'all|hosts|env' arguments, '| or' separated
01:40 requires SetEnvIf directive
01:50 Syntax Allow directive in .htaccess
01:52 Multiple Allow directives allowed in .htaccess file, each on a distinct row
02:01 or 1 Allow specifying the desired hosts, space separated
02:19 Note:The default state is to Allow everyone's access. Whoever configures the server will ' Allow from all'.
02:29 so using the Allow directive alone:
e.g.


Allow from all
or
Allow from 207.46.13.49
Allow from 66.249.64.0/255.255.224.0
..
..

in your .htaccess simply doesn't make sense
02:38 everyone has access to the server
02:44 Allow directive alone makes sense if the preferred configuration is to deny all access with a few exceptions that can be added in .htaccess if no access to server's core config file
e.g. Allow from...
02:53 All Access Denied but Googlebot is allowed access through .htaccess
02:55 you can Allow access to the whole server
.htaccess in htdocs (public_html)
03:01 or parts of your server: specific directories
.htaccess in 'files' directory

For more information about the htaccess file, please see the spec: apache.org