2. Allow directive | .htaccess Tutorial
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
1 | Allow 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:
- all
- IP
- host name (not recommended)
- 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 Allow ⁄ Deny directives.
Allow directive - Examples
1. Allow from all
1 | Allow from all |
2. Allow from host address (IP address)
1 | Allow from 66.249.79.76 |
1 | Allow from 66 |
1 | Allow from 66.249 |
1 | Allow from 66.249.79 |
1 | Allow from 66.249.79.76 207.46.13.49 |
1 | Allow from 66.249.64.0/255.255.224.0 |
1 | Allow from 66.249.64.0/19 |
1 | Allow from 2001:db8::a00:… |
1 | Allow from 2001:db8::a00:… /10 |
3. Allow from host name (domain) - not recommended! (requires HostnameLookups On)
1 | Allow from crawl-66-249-79-76.googlebot.com |
1 | Allow from .com |
1 | Allow from domain1.com domain2.com .fr de |
4. Allow from env (environment variable, SetEnvIf)
1 2 | SetEnvIf User-Agent "*.Trident.*$" 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 apache.org
file, please see the spec: