# Keep private files from being downloaded through the web server (Apache 2.4).
<FilesMatch "^(\.env.*|\.gitignore|composer\.(json|lock)|database\.sql)$">
  Require all denied
</FilesMatch>

# Composer libraries are not meant to be opened from the browser.
RedirectMatch 403 ^/(?:.*/)?vendor/

# Update 1: helper folders are never meant to be opened from the browser (also delete dev/ and tests/ before deploying).
RedirectMatch 404 ^/(?:.*/)?(?:dev|tests|tools|migrations|docs|storage)(?:/|$)

# Basic hardening headers (skipped automatically if mod_headers is not enabled).
# They do not change how any page works. Add Strict-Transport-Security yourself once the site runs on HTTPS only.
<IfModule mod_headers.c>
  Header always set X-Content-Type-Options "nosniff"
  Header always set X-Frame-Options "SAMEORIGIN"
  Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>
