Options -Indexes
RewriteEngine On

# HTTPS yönlendirme (SSL varsa etkinleştirin)
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Bakım modu (gerektiğinde açın)
# RewriteCond %{REQUEST_URI} !^/bakim\.php
# RewriteCond %{REQUEST_URI} !^/admin
# RewriteRule ^(.*)$ /bakim.php [R=302,L]

# Admin klasörü direkt erişim
RewriteRule ^admin/?$ /admin/giris.php [L]
RewriteRule ^admin/index/?$ /admin/index.php [L]

# Üye girişi kısa yollar
RewriteRule ^uye/?$ /uye/panel.php [L]
RewriteRule ^giris/?$ /uye/giris.php [L]
RewriteRule ^kayit/?$ /uye/kayit.php [L]

# İlçe sayfaları: /ilce/kadikoy
RewriteRule ^ilce/([a-z0-9-]+)/?$ /hizmet-ilce.php?ilce=$1 [L,QSA]

# Kategori sayfaları: /kategori/hali-yikama
RewriteRule ^kategori/([a-z0-9-]+)/?$ /hizmet-ilce.php?hizmet=$1 [L,QSA]

# Hizmet + İlçe: /hali-yikama/kadikoy
RewriteRule ^([a-z0-9-]+)/([a-z0-9-]+)/?$ /hizmet-ilce.php?hizmet=$1&ilce=$2 [L,QSA]

# Tek hizmet: /hali-yikama (sadece bilinen slug'lar için çalışır, diğerleri index)
# Bu kural gerekirse spesifik hizmet slug'ları için eklenebilir

# Mevcut dosya/dizin varsa işlem yapma
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# 404 yönlendirme
ErrorDocument 404 /404.php

# Güvenlik: includes klasörüne doğrudan erişimi engelle
<IfModule mod_rewrite.c>
  RewriteRule ^includes/ - [F,L]
</IfModule>

# Yükleme dizini için PHP çalıştırmayı engelle
<Directory "/uploads">
  php_flag engine off
  Options -ExecCGI
  RemoveHandler .php .php5 .phtml
  AddType text/plain .php .php5 .phtml
</Directory>

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

# Önbellek (statik dosyalar)
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/jpg "access plus 1 month"
  ExpiresByType image/jpeg "access plus 1 month"
  ExpiresByType image/png "access plus 1 month"
  ExpiresByType image/webp "access plus 1 month"
  ExpiresByType text/css "access plus 1 week"
  ExpiresByType text/javascript "access plus 1 week"
</IfModule>

# GZIP sıkıştırma
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/css application/javascript application/json
</IfModule>
