# PSC Portal — Apache Configuration
<IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
</IfModule>

# Permitir acesso a manifest.json e clients_data.json
<FilesMatch "\.(json|webmanifest)$">
    <IfModule mod_authz_core.c>
        Require all granted
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Allow from all
    </IfModule>
</FilesMatch>

AddType application/manifest+json .webmanifest .json
AddType application/javascript .js

# Regras de Reescrita & Retrocompatibilidade
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # 1. Retrocompatibilidade: Ficheiros de utilitários movidos para /ferramentas/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{DOCUMENT_ROOT}/ferramentas/$1 -f
    RewriteRule ^([^/]+\.html)$ /ferramentas/$1 [L,NC]

    # 2. Retrocompatibilidade: Ícones, favicons e logos movidos para /assets/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{DOCUMENT_ROOT}/assets/$1 -f
    RewriteRule ^(favicon.*|icon-.*|logo_transparente\.png)$ /assets/$1 [L,NC]
</IfModule>

# 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
