RewriteEngine On

# ----------------------------------------------------------------------
# | Compression                                                        |
# ----------------------------------------------------------------------
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/json application/xml
</IfModule>

# ----------------------------------------------------------------------
# | Browser caching                                                    |
# ----------------------------------------------------------------------
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/webp "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/pdf "access plus 1 month"
    ExpiresByType text/javascript "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType application/x-javascript "access plus 1 month"
    ExpiresByType application/json "access plus 1 month"
    ExpiresByType image/x-icon "access plus 1 year"
    ExpiresDefault "access plus 2 days"
</IfModule>
# 404 Error Page
ErrorDocument 404 /

# Dinamik robots.txt ve sitemap.xml (admin SEO panelinden)
RewriteRule ^robots\.txt$ /robots.php [L,QSA]
RewriteRule ^sitemap\.xml$ /sitemap.php [L,QSA]

# Ana sayfa ve genel sayfalar
RewriteRule ^tr$ index.php?page=index [L,QSA]
RewriteRule ^register/?$ index.php?page=register [L,QSA,NC]
RewriteRule ^promosyonlar/?$ index.php?page=promosyonlar [L,QSA,NC]
RewriteRule ^promotions/?$ index.php?page=promosyonlar [L,QSA,NC]
RewriteRule ^site\.webmanifest$ /static/xml/site.webmanifest [L]
RewriteRule ^favicon-32x32\.png$ /static/img/favicon-32x32.png [L]
RewriteRule ^favicon-16x16\.png$ /static/img/favicon-16x16.png [L]
RewriteRule ^apple-touch-icon\.png$ /static/img/favicon-32x32.png [L]
RewriteRule ^deposit$ index.php?page=deposit [L,QSA]
RewriteRule ^tr/dashboard/payments/deposit-money/?$ index.php?page=deposit [L,QSA]
RewriteRule ^deposit/([^/]+)/?$ /payment/payment.php?payment=$1 [L,QSA]
RewriteRule ^live-sports/?$ index.php?page=sports [L,QSA,NC]
RewriteRule ^sports/?$ index.php?page=sports [L,QSA,NC]
RewriteRule ^tr/authentication/signin/?$ index.php?page=login [L,QSA]

# Casino sayfaları (slash’li veya slash’siz, tireli veya tire siz)
RewriteRule ^live-?casino/?$ index.php?page=livecasino [L,QSA,NC]
RewriteRule ^tr/live-?casino/?$ index.php?page=livecasino [L,QSA,NC]
RewriteRule ^live-casino/cat/canlı-oyunlar$ index.php?page=livecasino [L,QSA]
RewriteRule ^live-casino/.+$ index.php?page=livecasino [L,QSA]

RewriteRule ^casino/?$ index.php?page=casino [L,QSA,NC]
RewriteRule ^tournaments(/.*)?$ index.php?page=tournaments [L,QSA,NC]
RewriteRule ^tr/tournaments(/.*)?$ index.php?page=tournaments [L,QSA,NC]
RewriteRule ^tr/casino/?$ index.php?page=casino [L,QSA,NC]

# Footer / yasal sayfalar (404 catch-all'dan önce)
RewriteRule ^sss/?$ index.php?page=sss [L,QSA]
RewriteRule ^firma-bilgileri/?$ index.php?page=firma-bilgileri [L,QSA]
RewriteRule ^saglayicilarimiz/?$ index.php?page=saglayicilarimiz [L,QSA]
RewriteRule ^sponsorluklar/?$ index.php?page=sponsorluklar [L,QSA]
RewriteRule ^odeme-yontemleri/?$ index.php?page=odeme-yontemleri [L,QSA]
RewriteRule ^terms-conditions/?$ index.php?page=terms-conditions [L,QSA]
RewriteRule ^gizlilik-politikasi/?$ index.php?page=gizlilik-politikasi [L,QSA]
RewriteRule ^sorumlu-oyun/?$ index.php?page=sorumlu-oyun [L,QSA]
RewriteRule ^iletisim/?$ index.php?page=iletisim [L,QSA]

# JSON / API yönlendirmeleri
RewriteRule ^api/kur/get-crypt$ api/get-crypt.php [L]
RewriteRule ^apijson/tr/bottom-mobile-menu/?$ api/bottom-mobile-menu.php [L,QSA]
RewriteRule ^casino/games/([^/]+)/?$ index.php?page=casino [L,QSA]
RewriteRule ^live-casino/games/([^/]+)/?$ index.php?page=livecasino [L,QSA]
RewriteRule ^api/bm/v1/banners/lists/2218/tr/center-main-slider/home-page/false/?$ /slider.php [L]
RewriteRule ^api/bm/v1/banners/lists/2218/tr/center-navbar/home-page/false/?$ /homepage.json [L]
RewriteRule ^api/bm/v1/banners/lists/2218/tr/center-navbar-2/home-page/false/?$ /spornavbar.json [L]
RewriteRule ^api/bm/v1/banners/lists/2218/tr/center-navbar-3/home-page/false/?$ /spornavbar2.json [L]

# Oyun sayfaları
RewriteRule ^game/([^/]+)/?$ index.php?page=game&game-id=$1 [L,QSA]

# Geçmiş ve bonus sayfaları
RewriteRule ^payment-history/?$ index.php?page=paymenthistory [L,QSA]
RewriteRule ^gaming-history/?$ index.php?page=gaminghistory [L,QSA]
RewriteRule ^bonus-history/?$ index.php?page=bonushistory [L,QSA]
RewriteRule ^cark/?$ /cark.php [L,QSA,NC]
RewriteRule ^hazine-avi/?$ /cark.php [L,QSA,NC]

# 404 olanları ana sayfaya 301 yönlendir
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . / [R=301,L]

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php82” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php82 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
