When we want to block bots, spam referrers using .htaccess file, some websites use following code syntax:
Order allow,deny
Allow from all
Deny from env=spambot
But some websites tell that we need to use different codes for different Apache versions:
#For Apache 2.2
<IfModule !mod_authz_core.c>
<IfModule mod_authz_host.c>
Order allow,deny
Allow from all
Deny from env=spambot
</IfModule>
</IfModule>
# For Apache 2.4
<IfModule mod_authz_core.c>
<RequireAll>
Require all granted
Require not env spambot
</RequireAll>
</IfModule>
Now I want to which cone is correct or both are correct?
Best Answer
This.
The syntax changed from Apache 2.2 to 2.4. However, the old (Apache 2.2) syntax was kept (in fact, it was moved to a different module: mod_access_compat) for backwards compatibility only - so it still "works". But it is deprecated and is likely to be removed in future versions. So, code on Apache 2.4 should use the
Require ...
syntax.