# PolicyAdmin - Apache Configuration (Production - billkarle.com root)

RewriteEngine On
RewriteBase /

# HTTPS is handled by the hosting platform / CDN / control-panel SSL.
# The HSTS header below ensures browsers always use HTTPS after the first
# visit.  We intentionally do NOT add a RewriteRule redirect here because
# the server sits behind an SSL-terminating proxy that strips the HTTPS
# flag; a redirect here would create an infinite loop (500 error).

RewriteRule ^api/ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.+)$ index.php?route=$1 [QSA,L]

<IfModule mod_headers.c>
    Header set X-Content-Type-Options "nosniff"
    Header set X-Frame-Options "SAMEORIGIN"
    Header set X-XSS-Protection "1; mode=block"
    Header set Referrer-Policy "strict-origin-when-cross-origin"
    Header set Strict-Transport-Security "max-age=31536000; includeSubDomains"
    Header set Permissions-Policy "camera=(), microphone=(), geolocation=()"
</IfModule>

<FilesMatch "\.(sql|md|env|gitignore|log|zip|bak|old|tmp)$">
    Require all denied
</FilesMatch>

<Files "install.php">
    Require all denied
</Files>

<IfModule mod_php.c>
    php_value upload_max_filesize 10M
    php_value post_max_size 12M
    php_value max_execution_time 60
    php_value memory_limit 128M
    php_flag display_errors off
    php_flag log_errors on
    php_value error_log logs/php_error.log
</IfModule>

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/json
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
</IfModule>
