RewriteEngine On

# Özel uygulama dizinleri hiçbir zaman web üzerinden yayınlanmaz.
RewriteRule ^(?:database|addons|cron_tasks|cache/viewers|vendor)(?:/|$) - [F,L,NC]
RewriteRule ^uploads/(?:pm|pms|topic_attachments|verifications)(?:/|$) - [F,L,NC]

# Yükleme klasörlerinde çalıştırılabilir dosyaları engelle.
RewriteRule ^uploads/.*\.(?:php[0-9]*|phtml|phar|cgi|pl|py|sh|shtml)$ - [F,L,NC]

# Yapılandırma, kilit, bakım ve gizli test dosyaları doğrudan açılamaz.
<FilesMatch "^(?:config\.php|composer\.(?:json|lock)|\.forium-installed|\.maintenance|\.forium-security-probe-.*)$">
<IfModule mod_authz_core.c>
  Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
  Order allow,deny
  Deny from all
</IfModule>
</FilesMatch>

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^konu/([0-9]+)(?:-[a-zA-Z0-9_-]+)?/?$ topic.php?id=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^kategori/([0-9]+)(?:-[a-zA-Z0-9_-]+)?/?$ category.php?id=$1 [L,QSA]

RewriteRule ^eklenti/([a-zA-Z0-9._-]+)/?$ addon_route.php?route=$1 [L,QSA]
RewriteRule ^sitemap\.xml$ sitemap.php [L,QSA]
RewriteRule ^robots\.txt$ robots.php [L,QSA]
RewriteRule ^rss\.xml$ rss.php [L,QSA]
RewriteRule ^feed\.xml$ rss.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^@([a-zA-Z0-9_-]+)$ profile.php?username=$1 [L,QSA]

RewriteRule ^blog/sayfa/([0-9]+)/?$ blog.php?page=$1 [L,QSA]
RewriteRule ^blog/([a-zA-Z0-9_-]+)/?$ blog.php?slug=$1 [L,QSA]
RewriteRule ^blog/?$ blog.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9][a-zA-Z0-9_-]*)/?$ custom_page.php?slug=$1 [L,QSA]
