# Tom's Java Jive - Apache Configuration

# Enable URL rewriting
RewriteEngine On

# Force HTTPS (uncomment in production)
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Remove trailing slashes
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Protect sensitive directories
RedirectMatch 403 /config/.*$
RedirectMatch 403 /includes/.*\.php$
RedirectMatch 403 /install/.*$

# Set default charset
AddDefaultCharset UTF-8

# Disable directory listing
Options -Indexes

# Set timezone (optional)
# php_value date.timezone "America/New_York"

# Increase upload limits (adjust as needed)
php_value upload_max_filesize 10M
php_value post_max_size 10M

# Enable compression (optional)
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript application/javascript application/json
</IfModule>

# Browser caching (optional)
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/webp "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 set X-Content-Type-Options "nosniff"
    Header set X-Frame-Options "SAMEORIGIN"
    Header set X-XSS-Protection "1; mode=block"
</IfModule>

# Custom error pages (optional)
# ErrorDocument 404 /404.php
# ErrorDocument 500 /500.php