<IfModule mod_rewrite.c>
RewriteEngine On

# 🔹 Base path fix (important for subfolder)
RewriteBase /MyAllTools/api/

# ✅ 1. If exact file exists → serve it
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

# ✅ 2. If directory exists → serve it
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# ✅ 3. If .php file exists → serve it (remove .php)
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L]

# ✅ 4. Otherwise → route to index.php
RewriteRule ^(.+)$ index.php?path=$1 [L,QSA]

</IfModule>