# Because of large data like double confirmation array,
# memory limit should be increased to 1GB.
# Better set this in php.ini, .user.ini, or cPanel MultiPHP INI Editor.
# php_value memory_limit 1024M

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Force HTTPS
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    # Preserve Authorization Header
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Route API requests inside /bckash/api
    RewriteBase /bckash/api/

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>

<IfModule mod_headers.c>
    Header always set Access-Control-Allow-Origin "*"
    Header always set Access-Control-Max-Age "3600"
    Header always set Access-Control-Allow-Methods "GET, POST, OPTIONS, DELETE, PUT"
    Header always set Access-Control-Allow-Headers "Authorization, X-API-KEY, Origin, X-Requested-With, Content-Type, Cache-Control, Accept, Access-Control-Request-Method, X-Auth-Signature"
</IfModule>

# cPanel PHP handler
<IfModule mime_module>
    AddHandler application/x-httpd-ea-php81 .php .php8 .phtml
</IfModule>