PHP built-in web server and CakePHP rewrite rules

app/webroot/rewrite.php:

<?php
$path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
// If the file exists then return false and let the server handle it
if (file_exists($_SERVER["DOCUMENT_ROOT"] . $path)) {
  return false;
} else {
  include __DIR__ . '/index.php';
}
?>

Then start with:

php -S localhost:8080 rewrite.php

Resource: http://www.sitepoint.com/taking-advantage-of-phps-built-in-server/

One thought on “PHP built-in web server and CakePHP rewrite rules”

Leave a Reply to Angel S. Moreno Cancel reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>