# ملف .htaccess لنظام الشحن
# تم تحديثه للاستضافة

# منع عرض محتويات المجلدات
Options +FollowSymLinks -Indexes

# تفعيل محرك إعادة الكتابة
RewriteEngine On

# توجيه الصفحة الرئيسية
DirectoryIndex index.php unified-dashboard.php

# إعادة توجيه صفحة التقارير الأسبوعية
RewriteRule ^weekly-reports$ weekly-reports.php [L]
RewriteRule ^weekly-reports/$ weekly-reports.php [L]

# إعادة توجيه صفحة التقارير الشهرية
RewriteRule ^monthly-reports$ monthly-reports.php [L]
RewriteRule ^monthly-reports/$ monthly-reports.php [L]

# إعادة توجيه صفحة التصدير
RewriteRule ^export$ export.php [L]
RewriteRule ^export/$ export.php [L]

# إعادة توجيه لوحة التحكم الموحدة
RewriteRule ^dashboard$ unified-dashboard.php [L]
RewriteRule ^dashboard/$ unified-dashboard.php [L]

# تعيين ترميز الصفحات
AddDefaultCharset UTF-8

# تعيين منطقة زمنية
SetEnv TZ Asia/Riyadh

# تعيين صفحات الخطأ
ErrorDocument 404 /404.php
ErrorDocument 403 /403.php
ErrorDocument 500 /500.php

# منع الوصول إلى ملفات حساسة
<FilesMatch "^\.env|\.gitignore|composer\.json|composer\.lock|package\.json|package-lock\.json|README\.md|INSTRUCTIONS\.md|\.git">
    Order allow,deny
    Deny from all
</FilesMatch>

# منع الوصول إلى مجلدات حساسة
<FilesMatch "^\.git|\.vscode|\.env|\.gitignore">
    Order allow,deny
    Deny from all
</FilesMatch>

# منع الوصول إلى مجلدات حساسة
<IfModule mod_rewrite.c>
    RewriteRule ^(\.git|\.vscode|logs|backups|database)(/|$) - [F,L]
</IfModule>

# حماية ملفات PHP
<FilesMatch "\.php$">
    # تأكد من أن الملف يتم تنفيذه كـ PHP
    SetHandler application/x-httpd-php
</FilesMatch>

# تعيين سياسة أمان المحتوى
<IfModule mod_headers.c>
    Header set X-Content-Type-Options "nosniff"
    Header set X-XSS-Protection "1; mode=block"
    Header set X-Frame-Options "SAMEORIGIN"
    Header set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

# تعيين سياسة الكوكيز
<IfModule mod_headers.c>
    Header always edit Set-Cookie (.*) "$1; HttpOnly; SameSite=Strict"
</IfModule>

# ضغط المحتوى
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript application/x-javascript application/json
</IfModule>