# GBCOPTRST — Apache rules for cPanel shared hosting
Options -Indexes
DirectoryIndex index.php
ServerSignature Off

<IfModule mod_rewrite.c>
  RewriteEngine On
  # Uncomment the next two lines after SSL is active to force HTTPS:
  # RewriteCond %{HTTPS} !=on
  # RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

  # Block direct access to application internals, config, storage, database, tests and docs
  RewriteRule ^(app|config|storage|database|tests|docs)(/|$) - [F,L]
  # Block dotfiles (except .well-known for SSL validation) and sensitive file types
  RewriteRule (^|/)\.(?!well-known/) - [F,L]
  RewriteRule \.(sql|md|log|lock|ini|sh|bak|dist|example)$ - [F,L,NC]
</IfModule>

<FilesMatch "\.(sql|md|log|lock|ini|sh|bak|dist|example)$">
  Require all denied
</FilesMatch>

<IfModule mod_headers.c>
  Header always set X-Content-Type-Options "nosniff"
  Header always set X-Frame-Options "DENY"
  Header always set Referrer-Policy "same-origin"
  Header always unset X-Powered-By
</IfModule>

<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/css "access plus 7 days"
  ExpiresByType application/javascript "access plus 7 days"
  ExpiresByType image/svg+xml "access plus 30 days"
</IfModule>

# PHP settings (honoured on hosts that run PHP as an Apache module; for
# PHP-FPM/LSAPI use cPanel > MultiPHP INI Editor instead — see docs).
<IfModule mod_php.c>
  php_flag display_errors Off
  php_flag expose_php Off
  php_value session.cookie_httponly 1
  php_value session.use_strict_mode 1
</IfModule>
