Options -Indexes
ServerSignature Off

# Rewrite rules
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /tajirika/

    # API routing - send to api/index.php
    RewriteRule ^api/(.*)$ api/index.php [QSA,L]

    # Block install folder after installation
    RewriteCond %{DOCUMENT_ROOT}/tajirika/includes/installed.lock -f
    RewriteRule ^install/ - [F,L]
</IfModule>

# Security Headers
<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"
</IfModule>

# Protect sensitive files
<FilesMatch "\.(sql|log|lock|env|md|json|lock)$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

# Protect config and includes
<FilesMatch "^(config|Database|Auth|helpers)\.php$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

# PHP settings
<IfModule mod_php.c>
    php_flag display_errors Off
    php_value upload_max_filesize 5M
    php_value post_max_size 10M
    php_value max_execution_time 60
    php_value memory_limit 128M
</IfModule>

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

# Browser caching for assets
<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 month"
    ExpiresByType image/jpeg "access plus 1 month"
</IfModule>
