RewriteEngine On
RewriteBase /

# 0. Gerçek dosya varsa PHP'ye yönlendirme
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

# 1. /dosya/123 → dosya.php?id=123
RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)$ $1.php?id=$2 [L,QSA]

# 2. /dosya → dosya.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([a-zA-Z0-9_-]+)$ $1.php [L]

# 3. .php uzantılı linkleri otomatik olarak uzantısız haline yönlendir
RewriteCond %{THE_REQUEST} \s/+([a-zA-Z0-9_-]+)\.php[\s?]
RewriteRule ^ %1 [R=301,L]

# (Güvenlik başlıkları vs. varsa buraya gelir)

# 4. Zararlı GET isteklerini engelle (isteğe bağlı)
RewriteCond %{QUERY_STRING} (\<|\>|\"|\'|\%3C|\%3E|\%22|\%27) [NC]
RewriteRule ^ - [F]

# 5. Güvenlik başlıkları (Content-Security-Policy hariç)
<IfModule mod_headers.c>
    Header set X-Content-Type-Options "nosniff"
    Header set X-Frame-Options "DENY"
    Header set X-XSS-Protection "1; mode=block"
</IfModule>

# 6. Ana sayfa olarak index.php'yi kullan
DirectoryIndex index.php

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php8_module>
   php_flag display_errors Off
   php_value max_execution_time 2000
   php_value max_input_time 2000
   php_value max_input_vars 1000
   php_value memory_limit 128M
   php_value post_max_size 2000M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php81"
   php_value upload_max_filesize 500M
   php_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
   php_flag display_errors Off
   php_value max_execution_time 2000
   php_value max_input_time 2000
   php_value max_input_vars 1000
   php_value memory_limit 128M
   php_value post_max_size 2000M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php81"
   php_value upload_max_filesize 500M
   php_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated php ini directives, do not edit
