Options -Indexes
DirectoryIndex login.php index.php

<IfModule mod_rewrite.c>
RewriteEngine On

# Block direct web access to internal application directories.
RewriteCond %{THE_REQUEST} \s/+(.*/)?(?:includes|database|docs|tests)/ [NC]
RewriteRule ^ - [F,L]

# Block hidden paths and known exposed log/backup filenames.
RewriteRule (^|/)\. - [F,L]
RewriteRule (^|/)(error_log|master-dashboard)$ - [F,L,NC]

# Clean public student URLs.
# /core/login.php and /core/index.php become /core/
RewriteCond %{THE_REQUEST} \s/+(.*/)?(?:login|index)\.php(?:[?\s]) [NC]
RewriteRule ^(?:login|index)\.php$ ./ [R=302,L,NE]

# /core/student/dashboard.php becomes /core/dashboard
RewriteCond %{THE_REQUEST} \s/+(.*/)?student/dashboard\.php(?:[?\s]) [NC]
RewriteRule ^student/dashboard\.php$ dashboard [R=302,L,NE]

# Internally serve the existing student dashboard file without changing it.
RewriteRule ^dashboard/?$ student/dashboard.php [END,QSA]
</IfModule>

<FilesMatch "(^\.|^error_log$|^master-dashboard$|\.env$|\.ini$|\.log$|\.sql$|\.zip$|\.bak$|\.old$|\.dist$|\.example\.php$|config\.local\.php$|composer\.(json|lock)$|package(-lock)?\.json$)">
  Require all denied
</FilesMatch>

<IfModule mod_headers.c>
Header always set X-Content-Type-Options "nosniff"
Header always set X-Frame-Options "SAMEORIGIN"
Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

<IfModule mod_php.c>
php_flag display_errors Off
php_flag log_errors On
php_value upload_max_filesize 20M
php_value post_max_size 24M
php_value max_execution_time 120
</IfModule>
