# =========================================================
# THE STARTING POINT — .htaccess (Apache / cPanel)
# Radi i kad je stranica u podfolderu.
# =========================================================
Options -Indexes
DirectoryIndex index.html index.php
AddDefaultCharset UTF-8

# MIME tipovi
<IfModule mod_mime.c>
  AddType font/woff2 .woff2
  AddType image/webp .webp
  AddType image/svg+xml .svg
  AddType application/manifest+json .webmanifest
</IfModule>

# Zaštita konfiguracijskih datoteka
<FilesMatch "^(config|mail-template)\.php$">
  <IfModule mod_authz_core.c>
    Require all denied
  </IfModule>
  <IfModule !mod_authz_core.c>
    Order allow,deny
    Deny from all
  </IfModule>
</FilesMatch>

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

# Cache (CSS/JS imaju ?v= verziju)
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 1 hour"
  ExpiresByType text/html "access plus 0 seconds"
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"
  ExpiresByType font/woff2 "access plus 1 year"
  ExpiresByType image/webp "access plus 6 months"
  ExpiresByType image/jpeg "access plus 6 months"
  ExpiresByType image/png "access plus 6 months"
  ExpiresByType image/svg+xml "access plus 6 months"
</IfModule>

# Sigurnosna zaglavlja
<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"
  Header always set Permissions-Policy "geolocation=(self), camera=(), microphone=()"
  <FilesMatch "\.(woff2)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>

# ---------------------------------------------------------
# KAD STRANICA PREĐE NA PRAVU DOMENU (u root public_html):
# maknite "#" ispred sljedećih redaka
# ---------------------------------------------------------
# ErrorDocument 404 /404.html
# <IfModule mod_rewrite.c>
#   RewriteEngine On
#   RewriteCond %{HTTPS} off
#   RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#   RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
#   RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]
# </IfModule>
