# .htaccess - cPanel için FINAL

# PHP Handler
AddHandler application/x-httpd-ea-php81 .php

# Rewrite Engine
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    
    # API isteklerini public/index.php'ye yönlendir
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^api/(.*)$ public/index.php [QSA,L]
    
    # public klasörü olmadan erişimleri düzelt
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(admin|user|assets|login\.html)(.*)$ public/$1$2 [L]
</IfModule>

# Güvenlik
<FilesMatch "^(config\.php|\.env|\.sql|\.log)$">
    Order allow,deny
    Deny from all
</FilesMatch>

# Charset
AddDefaultCharset UTF-8

# Security Headers
<IfModule mod_headers.c>
    Header set X-Content-Type-Options "nosniff"
    Header set X-Frame-Options "SAMEORIGIN"
    Header set X-XSS-Protection "1; mode=block"
</IfModule>