# Incluir dentro del bloque server HTTPS existente.
# Se asume: root /var/www/html;

location ^~ /microerp/ {
    index index.php;
    try_files $uri $uri/ =404;

    location ~ ^/microerp/producto/([a-z0-9-]+)/?$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        fastcgi_param SCRIPT_FILENAME /var/www/html/microerp/producto.php;
        fastcgi_param QUERY_STRING slug=$1&$query_string;
    }

    location = /microerp/sitemap.xml {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        fastcgi_param SCRIPT_FILENAME /var/www/html/microerp/sitemap.php;
    }

    location = /microerp/robots.txt {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        fastcgi_param SCRIPT_FILENAME /var/www/html/microerp/robots.php;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~ ^/microerp/(app|config|database|deploy|docs|scripts|storage|tests)/ {
        deny all;
    }

    location ~ ^/microerp/uploads/.*\.php$ {
        deny all;
    }

    location ~* \.(sqlite|sqlite-wal|sqlite-shm|sql|log|sh|md)$ {
        deny all;
    }
}
