# ------------------------------------------------------------
#  Üst dizindeki .htaccess (proje kökü) varsayılan olarak HER ŞEYİ
#  engeller. Bu dizin (public/) ve altındaki her şeye erişimi
#  burada yeniden açıyoruz - asıl site içeriği burası.
# ------------------------------------------------------------
<IfModule mod_authz_core.c>
    Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
    Order allow,deny
    Allow from all
</IfModule>

# ------------------------------------------------------------
#  Yönlendirme: gerçek dosya/dizin yoksa her şeyi index.php'ye yolla
# ------------------------------------------------------------
<IfModule mod_rewrite.c>
    RewriteEngine On

    # Alt klasöre kurulduysa otomatik tespit
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]

    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

# ------------------------------------------------------------
#  Güvenlik başlıkları
# ------------------------------------------------------------
<IfModule mod_headers.c>
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set X-Content-Type-Options "nosniff"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
    Header always set X-XSS-Protection "1; mode=block"
    Header always set Permissions-Policy "geolocation=(), microphone=(), camera=()"
</IfModule>

# ------------------------------------------------------------
#  Hassas dosya / dizinlere erişimi engelle
# ------------------------------------------------------------
<FilesMatch "^(\.env.*|composer\.(json|lock)|package(-lock)?\.json|.*\.(sql|log|md))$">
    Require all denied
</FilesMatch>

<IfModule mod_rewrite.c>
    RewriteRule ^(storage|database|app|config|vendor|src|node_modules)(/.*)?$ - [F,L]
</IfModule>

Options -Indexes
ServerSignature Off

# ------------------------------------------------------------
#  Statik varlıklar için tarayıcı cache
# ------------------------------------------------------------
<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 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/webp "access plus 1 month"
    ExpiresByType image/svg+xml "access plus 1 month"
    ExpiresByType font/woff2 "access plus 1 year"
</IfModule>
