# PawnDrive — Apache configuration (Afrihost cPanel compatible)
# This file lives in the subdomain document root, alongside index.php.

# Pretty URLs: /how-it-works -> index.php?page=how-it-works
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9-]+)/?$ index.php?page=$1 [L,QSA]

# Default charset
AddDefaultCharset utf-8

# Security headers
<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"
  Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()"
</IfModule>

# Block application internals from the web.
# (RedirectMatch mod_alias is valid in .htaccess and works on Apache 2.2 and 2.4.)
RedirectMatch 403 ^/src(/|$)
RedirectMatch 403 ^/storage(/|$)
RedirectMatch 403 ^/database(/|$)
RedirectMatch 403 ^/docs(/|$)
# Disabled installer backup must never be downloadable as source
RedirectMatch 403 ^/install\.php\.done$

# Block dotfiles
<FilesMatch "^\.">
  <IfModule mod_authz_core.c>
    Require all denied
  </IfModule>
  <IfModule !mod_authz_core.c>
    Order allow,deny
    Deny from all
  </IfModule>
</FilesMatch>

# Compression + caching
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/css application/javascript image/svg+xml
</IfModule>
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/jpeg "access plus 30 days"
  ExpiresByType image/png "access plus 30 days"
  ExpiresByType image/webp "access plus 30 days"
  ExpiresByType text/css "access plus 7 days"
  ExpiresByType application/javascript "access plus 7 days"
</IfModule>
