# ---- Birthday Wish System: web root hardening ----
Options -Indexes -MultiViews
ServerSignature Off
DirectoryIndex index.php

<IfModule mod_rewrite.c>
  RewriteEngine On
  # Force HTTPS
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP:X-Forwarded-Proto} !=https
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  # Block common attack patterns in query strings
  RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
  RewriteCond %{QUERY_STRING} (union.*select|concat\(|information_schema|sleep\(|benchmark\() [NC,OR]
  RewriteCond %{QUERY_STRING} (\.\./|%2e%2e%2f|/etc/passwd|base64_encode|GLOBALS|_REQUEST) [NC]
  RewriteRule ^ - [F,L]
  # Disallow TRACE/TRACK
  RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|PUT|DELETE)$ [NC]
  RewriteRule ^ - [F,L]
</IfModule>

# Deny hidden files, backups, and source/config files
<FilesMatch "(^\.|\.(bak|old|orig|save|swp|sql|log|ini|env|sh|inc|dist|md|lock|json)$|~$)">
  Require all denied
</FilesMatch>

# Only PHP pages + static assets can be requested; never execute PHP inside assets/
<IfModule mod_headers.c>
  Header always unset X-Powered-By
  Header always set X-Content-Type-Options "nosniff"
</IfModule>

# Upload / request limits (if host allows php_value in .htaccess; otherwise set in MultiPHP INI Editor)
<IfModule mod_php.c>
  php_flag display_errors Off
  php_flag expose_php Off
  php_value upload_max_filesize 3M
  php_value post_max_size 4M
  php_value max_input_vars 2000
  php_flag session.cookie_httponly On
  php_flag session.use_strict_mode On
</IfModule>

LimitRequestBody 5242880
