Options -MultiViews
RewriteEngine On

# ─── إعادة التوجيهات ───────────────────────────
# تحويل index.php إلى /
RewriteCond %{THE_REQUEST} \s/index\.php[\s?] [NC]
RewriteRule ^index\.php$ / [R=301,L]

# تحويل index.html إلى /
RewriteCond %{THE_REQUEST} \s/index\.html[\s?] [NC]
RewriteRule ^index\.html$ / [R=301,L]

# Force HTTPS and redirect all to a1.anakbnet.online
<IfModule mod_rewrite.c>
RewriteEngine On

# إعادة التوجيه من أي دومين أو www إلى https://a1.anakbnet.online/
RewriteCond %{HTTP_HOST} !^a1\.anakbnet\.online$ [NC]
RewriteRule ^(.*)$ https://a1.anakbnet.online/$1 [L,R=301]

# إعادة التوجيه من http إلى https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://a1.anakbnet.online/$1 [L,R=301]
</IfModule>

# تعطيل عرض الفهارس
Options -Indexes

# دعم الروابط الأخرى
RewriteRule ^browse\.html$ category.php [L,NC]
RewriteRule ^browse-(.*)-videos\.html$ category.php?cat=$1 [L,QSA,NC]
RewriteRule ^browse-(.*)-videos-([0-9]+)-(.*)\.html$ category.php?cat=$1&page=$2&sortby=$3 [L,QSA,NC]
RewriteRule ^videos\.(flv|mp4)(.*)$ videos.php$2 [L,NC]
RewriteRule ^(register|contact)\.html$ $1.php [L,NC,R=301]
RewriteRule ^contact\.html$ contact.php [L]

# ─── ضغط GZIP ────────────────────────────────
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css text/javascript
  AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/json
  AddOutputFilterByType DEFLATE application/javascript application/x-javascript
  AddOutputFilterByType DEFLATE font/ttf font/otf font/woff font/woff2
  AddOutputFilterByType DEFLATE image/svg+xml image/webp
</IfModule>

# ─── الكاش ───────────────────────────────────
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/html "access plus 0 seconds"
  ExpiresByType application/xhtml+xml "access plus 0 seconds"
  ExpiresByType application/javascript "access plus 1 month"
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType video/mp4 "access plus 1 year"
  ExpiresByType audio/mpeg "access plus 1 year"
  ExpiresByType application/font-woff "access plus 1 year"
  ExpiresByType application/font-woff2 "access plus 1 year"
</IfModule>

# ─── Cache-Control headers للـ CSS/JS ──────────────
<IfModule mod_headers.c>
  <FilesMatch "\.(css|js)$">
    Header set Cache-Control "max-age=2592000, public"
  </FilesMatch>
</IfModule>

# ─── حماية ───────────────────────────────────
<IfModule mod_headers.c>
  Header set X-Content-Type-Options "nosniff"
  Header always append X-Frame-Options SAMEORIGIN
  Header set X-XSS-Protection "1; mode=block"
  Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
  Header set Referrer-Policy "no-referrer-when-downgrade"
  <FilesMatch "\.webp$">
    Header set Cache-Control "max-age=31536000, public"
  </FilesMatch>
</IfModule>

# ─── HTTPS ───────────────────────────────────
<IfModule mod_rewrite.c>
  RewriteCond %{HTTPS} off
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php8_module>
   php_value memory_limit 512M
   php_value max_execution_time 120
   php_value upload_max_filesize 64M
   php_value post_max_size 64M
   php_flag zlib.output_compression On
   php_value zlib.output_compression_level 6
</IfModule>
<IfModule lsapi_module>
   php_value memory_limit 512M
   php_value max_execution_time 120
   php_value upload_max_filesize 64M
   php_value post_max_size 64M
   php_flag zlib.output_compression On
   php_value zlib.output_compression_level 6
</IfModule>
# END cPanel-generated php ini directives, do not edit

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php81” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php81 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
