Uncategorized

Direct Access Static Files in Google’s Project IDX

<?php
// index.php

// Serve static files directly if they exist
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$ext = pathinfo($path, PATHINFO_EXTENSION);

if ($ext && in_array($ext, ['css', 'js', 'png', 'jpg', 'jpeg', 'gif'])) {
    if (file_exists(__DIR__ . $path)) {
        return false; // serve the requested resource as-is.
    }
}

// Your PHP code goes here

Leave a Reply

Your email address will not be published. Required fields are marked *