Friendly URLs on PHP 5.4 Embedded Server

I usually use Apache as a web server for my php applications. But I just found that php 5.4 comes with a built-in web server.

In the first application I tried to download php -S, I noticed that the rewrite rules are not enabled or do not work properly.

Does anyone know if an embedded server has such a thing?

+3
source share
1 answer

In the Embedded Web Server section of the manual:

PHP , - "" script. script HTTP-. script FALSE, . script .

<?php
// routing.php
if (preg_match('/\.(?:png|jpg|jpeg|gif)$/', $_SERVER["REQUEST_URI"])) {
    return false;
} else {
    include __DIR__ . '/index.php';
}

:

php -S localhost:8888 routing.php

: http://gonzalo123.com/2012/10/15/how-to-rewrite-urls-with-php-5-4s-built-in-web-server/

- . . -. .

+4
source

All Articles