PHP built in server and .htaccess mod rewrites

Here’s the router that I use for the builtin php webserver that serves assets from the filesystem if they exist and otherwise performs a rewrite to an index.php file. Run using: php -S localhost:8080 router.php router.php: <?php chdir(__DIR__); $filePath = realpath(ltrim($_SERVER[“REQUEST_URI”], “https://stackoverflow.com/”)); if ($filePath && is_dir($filePath)){ // attempt to find an index file foreach ([‘index.php’, … Read more