# INDPLS.in - Indianapolis Community Portal

RewriteEngine On

# Block access to sensitive directories
RewriteRule ^config/ - [F,L]
RewriteRule ^data/ - [F,L]
RewriteRule ^includes/ - [F,L]
RewriteRule ^templates/ - [F,L]
RewriteRule ^content/ - [F,L]
RewriteRule ^cron/ - [F,L]

# Block hidden files and sensitive extensions
<FilesMatch "^\.">
    Require all denied
</FilesMatch>

<FilesMatch "\.(json|sqlite|db|log|sh|md)$">
    Require all denied
</FilesMatch>

# Allow specific public files
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(index\.php|dashboard\.php)$ - [L]

# Allow assets directory
RewriteCond %{REQUEST_URI} ^/assets/
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

# Allow API directory
RewriteCond %{REQUEST_URI} ^/api/
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

# Route everything else through index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]

# 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>

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