# Cincinnati Fire Department Portal - Apache Configuration

# Force HTTPS
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

# Block direct access to sensitive files and directories
<FilesMatch "^\.env$">
    Require all denied
</FilesMatch>

<FilesMatch "^(config\.php|constants\.php|auth\.php|db\.php)$">
    Require all denied
</FilesMatch>

# Protect config/ and cron/ directories from direct web access
<IfModule mod_rewrite.c>
    RewriteRule ^config/ - [F,L]
    RewriteRule ^cron/ - [F,L]
</IfModule>

# Disable directory listing
Options -Indexes

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

# Session security
<IfModule mod_php.c>
    php_flag session.cookie_httponly On
    php_flag session.use_strict_mode On
    php_value session.cookie_samesite Strict
    php_value session.gc_maxlifetime 28800
    php_value upload_max_filesize 10M
    php_value post_max_size 12M
    php_value max_execution_time 300
    php_value memory_limit 256M
</IfModule>

# Prevent PHP execution in uploads directory
<IfModule mod_rewrite.c>
    RewriteRule ^uploads/.*\.ph(p[345]?|t|tml)$ - [F,L]
</IfModule>

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

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php82” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php82 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
