# ============================================
# BAITARI Platform — .htaccess
# NameHero cPanel Shared Hosting
# ============================================

Options -Indexes
ServerSignature Off

# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Remove .php extension (clean URLs)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

# Redirect /admin → /pages/admin.php
RewriteRule ^admin/?$ pages/admin.php [NC,L]
RewriteRule ^vet/([0-9]+)/?$ pages/vet-profile.php?id=$1 [NC,L]
RewriteRule ^emergency-map/?$ pages/emergency-map.php [NC,L]

# Protect sensitive files
<FilesMatch "(config|schema|composer)\.php$">
  Order Allow,Deny
  Deny from all
</FilesMatch>

# Cache static assets
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType application/json "access plus 1 day"
</IfModule>

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

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

# Default page
DirectoryIndex index.php
