# Public image URL compatibility layer. Actual files live outside public_html.
Options -Indexes
RewriteEngine On

# Route old and new /backend/uploads/<folder>/<filename> URLs through the
# safe PHP image reader. Keep the database image_url values unchanged.
RewriteRule ^(products|banners|categories|logos|favicons)/([A-Za-z0-9._-]+\.(?:jpg|jpeg|png|webp|gif))$ /backend/api/media.php?file=$1/$2 [L,NC,QSA]

<IfModule mod_authz_core.c>
  Require all granted
</IfModule>

# Never execute scripts in this compatibility directory.
<FilesMatch "\.(php|php[0-9]|phtml|phar)$">
  <IfModule mod_authz_core.c>
    Require all denied
  </IfModule>
</FilesMatch>

<IfModule mod_headers.c>
  Header set Access-Control-Allow-Origin "*"
</IfModule>
