# Güvenlik başlıkları
<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"
    Header set Content-Security-Policy "default-src 'self' https:; script-src 'self' 'unsafe-inline' 'unsafe-eval' https:; style-src 'self' 'unsafe-inline' https:; img-src 'self' data: https:; font-src 'self' data: https:; connect-src 'self' https:; frame-src 'self' https:;"
    Header set Referrer-Policy "strict-origin-when-cross-origin"
    Header set Permissions-Policy "geolocation=(), microphone=(), camera=()"
</IfModule>

# PHP hata gösterimini kapat
php_flag display_errors off

# Dizin listelemeyi kapat
Options -Indexes

# Hassas dosyalara erişimi engelle
<FilesMatch "^(\.htaccess|\.htpasswd|\.git|\.env|composer\.json|composer\.lock|package\.json|package-lock\.json)$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

# Admin dizini için özel kurallar
<Directory "admin">
    Options -Indexes
    AllowOverride All
    Require all granted
</Directory>

# PHP dosyalarını doğrudan çalıştırmayı engelle
<FilesMatch "\.php$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

# İzin verilen PHP dosyaları
<FilesMatch "^(index|detals|contact|sitemap)\.php$">
    Order Allow,Deny
    Allow from all
</FilesMatch>

# XML dosyalarına erişime izin ver
<FilesMatch "\.xml$">
    Order Allow,Deny
    Allow from all
</FilesMatch>

# Sitemap.xml için özel izin
<Files "sitemap.xml">
    Order Allow,Deny
    Allow from all
</Files>

# HTTPS yönlendirmesi (sitemap için istisna)
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/sitemap\.xml$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# www yönlendirmesi (sitemap için istisna)
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{REQUEST_URI} !^/sitemap\.xml$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Admin dizini için yönlendirme
RewriteRule ^admin/?$ admin/daxil-ol.php [L]

# Hata sehifelerı
ErrorDocument 404 /404.php
ErrorDocument 403 /403.php
ErrorDocument 500 /500.php

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 

RewriteRule ^g2aleri/? galeri2.php [NC,L]

RewriteRule ^([0-9a-zA-Z-_]+)$  detals.php?seo=$1 [L,QSA]




# PHP çalıştırma ayarları (Sadece bir tane PHP sürüm belirleyelim)
<IfModule mime_module>
AddHandler application/x-httpd-ea-php72___lsphp .php .php7 .phtml
</IfModule>

# Güvenlik: PHP çalıştırılabilir dosya uzantılarını sınırlama
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-ea-php72___lsphp
</FilesMatch>

# php -- BEGIN cPanel-generated handler, do not edit
# “alt-php72” paketini varsayılan “PHP” programlama dili olarak ayarlayın.
<IfModule mime_module>
  AddHandler application/x-httpd-alt-php72___lsphp .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
