Mittels .htaccess Datei kann man den Zugriff auf einzelne Dateien und Verzeichnisse einschränken. Dieser Syntax hat sich mit Apache 2.4 gegenüber 2.2 geändert.
Apache 2.4 versteht weiterhin die 2.2 Parameter, sofern das access_compat_module in der httpd.conf aktiviert ist:
LoadModule access_compat_module modules/mod_access_compat.so
Apache 2.2
Order deny,allow
Deny from all
Apache 2.4
Require all denied
Apache 2.2
Order allow,deny
Allow from all
Apache 2.4
Require all granted
Apache 2.2
Order Allow,Deny
Allow from all
Deny from badsite.com
Apache 2.4
<RequireAll>
Require all granted
Require not host badsite.com
</RequireAll>
Apache 2.2
Order Allow,Deny
Allow from all
Deny from 111.111.111.111
Deny from 222.222.222.222
Deny from 123.123.123.123
Apache 2.4
<RequireAll>
Require all granted
Require not ip 111.111.111.111
Require not ip 222.222.222.222
Require not ip 123.123.123.123
</RequireAll>
Apache 2.2
Order Deny,Allow
Deny from all
<If "%{REQUEST_URI} =~ m#\.(jpe?g|gif|png|tiff?|eps|pdf|css|zip|docx?|xlsx?|csv|mp4)$#i">
Order Allow,Deny
Allow from all
</If>
Apache 2.4
Require all denied
<If "%{REQUEST_URI} =~ m#\.(jpe?g|gif|png|tiff?|eps|pdf|css|zip|docx?|xlsx?|csv|mp4)$#i">
Require all granted
</If>
Apache 2.2
Order Allow,Deny
Allow from all
<If "%{REQUEST_URI} =~ m#/.*(composer\.json|composer\.lock|composer\.phar|.env|README.md)$#i">
Order Deny,Allow
Deny from all
</If>
Apache 2.4
Require all granted
<If "%{REQUEST_URI} =~ m#/.*(composer\.json|composer\.lock|composer\.phar|.env|README.md)$#i">
Require all denied
</If>