# فعال‌سازی تنظیمات Authorization
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
    Options +FollowSymlinks
    RewriteEngine On
   
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/manifest\.json$ [NC]
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} ^/logo\.png$ [NC]
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} ^/favicon\.ico$ [NC]
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} ^/sitemapindex\.xml$ [NC]
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} ^/sitemap-fa1\.xml$ [NC]
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} ^/sitemap-fa2\.xml$ [NC]
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} ^/sitemap-fa3\.xml$ [NC]
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} ^/sitemap-fa4\.xml$ [NC]
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} ^/robots\.txt$ [NC]
RewriteRule ^ - [L]

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On

    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
#    RewriteCond %{HTTPS} on
#   RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]

            # بررسی وجود فایل قبل از اعمال قوانین بازنویسی
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
        # قوانین برای پوشه آپلود

    #RewriteRule ^upload/(.*)$ upload/$1 [L]
    RewriteCond %{REQUEST_URI} ^/play/
    RewriteRule ^ - [L]

    RewriteCond %{REQUEST_URI} ^/upload/
    RewriteRule ^ - [L]

    # قوانین برای مسیرهای بخش مدیریت
    RewriteCond %{REQUEST_URI} !^upload/
    RewriteCond %{REQUEST_URI} !^play/
    RewriteCond %{REQUEST_URI} ^/(admin)
    RewriteRule ^admin/assets/(.*)$ backend/web/assets/$1 [L]
    RewriteRule ^admin/css/(.*)$ backend/web/css/$1 [L]
    RewriteRule ^admin/fonts/(.*)$ backend/web/fonts/$1 [L]
    RewriteRule ^admin/img/(.*)$ backend/web/img/$1 [L]
    RewriteRule ^admin/js/(.*)$ backend/web/js/$1 [L]

    # قوانین برای تغییر مسیر به index.php
    RewriteCond %{REQUEST_URI} !^upload/
    RewriteCond %{REQUEST_URI} !^play/
    RewriteCond %{REQUEST_URI} !^/backend/web/(assets|css|js|images|fonts)/
    RewriteCond %{REQUEST_URI} ^/(admin)
    RewriteRule ^.*$ backend/web/$1 [L]

    # قوانین دیگر برای منابع مختلف
    RewriteCond %{REQUEST_URI} ^/(assets|css|js|images)
    RewriteCond %{REQUEST_URI} !^upload/
    RewriteCond %{REQUEST_URI} !^play/
    RewriteCond %{REQUEST_URI} !^manifest.json
    RewriteCond %{REQUEST_URI} !^robots.txt
    RewriteCond %{REQUEST_URI} !^sitemapindex.xml
    RewriteRule ^assets/(.*)$ frontend/web/assets/$1 [L]
    RewriteRule ^assetsNew/(.*)$ frontend/web/assetsNew/$1 [L]
    RewriteRule ^css/(.*)$ frontend/web/css/$1 [L]
    RewriteRule ^fonts/(.*)$ frontend/web/fonts/$1 [L]
    RewriteRule ^js/(.*)$ frontend/web/js/$1 [L]

    # شرط‌های اضافی برای جلوگیری از تداخل
    RewriteCond %{REQUEST_URI} !^(frontend|backend)/web/(assets|css|js|images|assetsNew|fonts)/
    RewriteCond %{REQUEST_URI} !^upload/
    RewriteCond %{REQUEST_URI} !^play/
    RewriteRule ^.*$ frontend/web/$1 [L]
</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_flag display_errors Off
   php_value max_execution_time 300000000
   php_value max_input_time 60000000
   php_value max_input_vars 1000
   php_value memory_limit 5000M
   php_value post_max_size 800M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php83"
   php_value upload_max_filesize 200M
   php_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
   php_flag display_errors Off
   php_value max_execution_time 300000000
   php_value max_input_time 60000000
   php_value max_input_vars 1000
   php_value memory_limit 5000M
   php_value post_max_size 800M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php83"
   php_value upload_max_filesize 200M
   php_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated php ini directives, do not edit

# 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_flag display_errors Off
   php_value max_execution_time 300000000
   php_value max_input_time 60000000
   php_value max_input_vars 1000
   php_value memory_limit 5000M
   php_value post_max_size 800M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php82"
   php_value upload_max_filesize 200M
   php_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
   php_flag display_errors Off
   php_value max_execution_time 300000000
   php_value max_input_time 60000000
   php_value max_input_vars 1000
   php_value memory_limit 5000M
   php_value post_max_size 800M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php82"
   php_value upload_max_filesize 200M
   php_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated php ini directives, do not edit

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