# =========================================================================
# Policy.fit — Apache configuration (works on standard cPanel shared hosting)
# =========================================================================

DirectoryIndex index.php

# ----- Pretty URL: lets "yourdomain.com/adminji" load adminji.php -----
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME}.php -f
  RewriteRule ^([^/.]+)/?$ $1.php [L,QSA]
</IfModule>

# ----- Block direct access to files that should never be requested directly -----
<FilesMatch "^(config|db|helpers)\.php$">
  Require all denied
</FilesMatch>
<FilesMatch "\.(sql|txt)$">
  Require all denied
</FilesMatch>

# ----- 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 Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

# ----- Compression -----
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/css application/javascript text/javascript application/json image/svg+xml
</IfModule>

# ----- Caching for static assets -----
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
  ExpiresByType text/javascript "access plus 1 month"
  ExpiresByType image/svg+xml "access plus 1 month"
</IfModule>

# ----- Force HTTPS -----
# Uncomment the two lines below ONLY after SSL (the padlock) is active on
# your domain in cPanel. Turning this on before SSL is ready will make the
# site unreachable.
# RewriteCond %{HTTPS} off
# RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
