# TempMail Platform - Apache Configuration

# Enable rewrite engine
RewriteEngine On
RewriteBase /

# Protect sensitive files
<FilesMatch "^\.">
    Order allow,deny
    Deny from all
</FilesMatch>

# Protect config directory
RewriteRule ^config/ - [F,L]

# Protect classes directory
RewriteRule ^classes/ - [F,L]

# Protect database directory
RewriteRule ^database/ - [F,L]

# API requests - allow direct access
RewriteRule ^api/ - [L]

# Admin requests - allow direct access
RewriteRule ^admin/ - [L]

# Cron requests - allow direct access
RewriteRule ^cron/ - [L]

# Mailparser - allow direct access
RewriteRule ^mailparser/ - [L]

# Handle frontend routing
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

# Enable gzip compression
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/css application/javascript application/json
</IfModule>

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

# Security headers
<IfModule mod_headers.c>
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-XSS-Protection "1; mode=block"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

# PHP settings
php_value upload_max_filesize 10M
php_value post_max_size 10M
php_value max_execution_time 300
php_value memory_limit 256M
