RewriteEngine On

# 🔑 PASS AUTHORIZATION HEADER TO PHP (JWT FIX)
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

#RewriteCond %{REQUEST_URI} !/Under-Maintainance.jpg$ [NC]
#RewriteRule ^(.*)$ /Under-Maintainance.jpg [R=302,L]

RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

IndexIgnore *
ErrorDocument 404 /index.php

# take off index.html
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.php$ [NC]
RewriteRule . https://%{HTTP_HOST}%1 [R=301,NE,L]

## hide .php extension
RewriteCond %{REQUEST_METHOD} !POST [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

## internally redirect /foo → /foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]

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