# ==========================================================
#  Artist Portfolio CMS — إعدادات Apache
# ==========================================================

# ---- الترميز ----
AddDefaultCharset UTF-8

# ---- منع تصفّح المجلدات ----
Options -Indexes

# ---- حماية الملفات الحساسة ----
<FilesMatch "^(config\.php|schema\.sql|seed\.php|\.env|composer\.(json|lock))$">
  Require all denied
</FilesMatch>

# ---- الروابط اللطيفة (فعّلها من: لوحة التحكم ← الإعدادات ← روابط لطيفة) ----
<IfModule mod_rewrite.c>
  RewriteEngine On
  # RewriteBase /

  # تجاهل الملفات والمجلدات الموجودة فعلياً
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^ - [L]

  # لا تعالج لوحة التحكم أو الرفع
  RewriteRule ^(admin|uploads|assets)/ - [L]

  # /route/slug  →  index.php?route=route&slug=slug
  RewriteRule ^([a-zA-Z0-9_-]+)/([^/]+)/?$ index.php?route=$1&slug=$2 [QSA,L]
  # /route        →  index.php?route=route
  RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?route=$1 [QSA,L]
</IfModule>

# ---- ضغط المخرجات ----
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/javascript application/json image/svg+xml
</IfModule>

# ---- التخزين المؤقت للملفات الثابتة ----
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/jpeg  "access plus 1 month"
  ExpiresByType image/png   "access plus 1 month"
  ExpiresByType image/webp  "access plus 1 month"
  ExpiresByType image/svg+xml "access plus 1 month"
  ExpiresByType video/mp4   "access plus 1 month"
  ExpiresByType text/css    "access plus 7 days"
  ExpiresByType application/javascript "access plus 7 days"
</IfModule>

# ---- ترويسات أمان ----
<IfModule mod_headers.c>
  Header set X-Content-Type-Options "nosniff"
  Header set X-Frame-Options "SAMEORIGIN"
  Header set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

# ---- حجم الرفع (قد تتجاهله بعض الاستضافات) ----
<IfModule mod_php.c>
  php_value upload_max_filesize 256M
  php_value post_max_size 256M
  php_value max_execution_time 300
  php_value memory_limit 256M
</IfModule>
