RewriteEngine On
RewriteBase /

# إجبار استخدام HTTPS عبر Cloudflare
RewriteCond %{HTTP:X-Forwarded-Proto} =http
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301]

# تحويل الروابط الجميلة
RewriteRule ^tracking/([0-9a-zA-Z]+)$ index.php [L]
RewriteRule ^verify/account$ profile.php [L]
RewriteRule ^secure/session$ secure.php [L]
RewriteRule ^status/success$ finish.php [L]

# السماح بالوصول المباشر لملفات PHP في هذا المشروع فقط
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]

# حماية الملفات الحساسة
<FilesMatch "\.(env|log|sql|bak|txt)$">
    Order allow,deny
    Deny from all
</FilesMatch>
