# 1. منع تصفح المجلدات مباشرة
Options -Indexes

# 2. تحديد الملف الرئيسي
DirectoryIndex index.php

# 3. تفعيل المحرك وتجنب مشاكل إعادة التوجيه
<IfModule mod_rewrite.c>
    RewriteEngine On
    
    # حماية المجلدات والملفات الحساسة
    RewriteRule ^(config|helpers|middleware|database|storage|languages)/ - [F,L]
</IfModule>

# 4. منع الوصول للملفات الحساسة
<FilesMatch "\.(sql|log|md|env|json)$">
    Require all denied
</FilesMatch>

# 5. ضبط إعدادات PHP بأسلوب آمن لا يسبب خطأ 500/503
<IfModule mod_php7.c>
    php_flag display_errors off
</IfModule>
<IfModule mod_php.c>
    php_flag display_errors off
</IfModule>