# حماية الملفات الحساسة
<FilesMatch "^(config|classes|database)">
    Order allow,deny
    Deny from all
</FilesMatch>

# تفعيل Rewrite Engine
RewriteEngine On

# السماح بجميع الملفات الموجودة (يجب أن تكون أول قاعدة)
# Allow all existing files (must be first rule)
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

# السماح بجميع المجلدات الموجودة
# Allow all existing directories
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# إعادة توجيه إلى index.php إذا كان الملف غير موجود
# Redirect to index.php if file doesn't exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]

# حماية من XSS
<IfModule mod_headers.c>
    Header set X-XSS-Protection "1; mode=block"
    Header set X-Content-Type-Options "nosniff"
    Header set X-Frame-Options "SAMEORIGIN"
</IfModule>

# تعطيل عرض قائمة الملفات
Options -Indexes

# ضغط الملفات
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
</IfModule>

