DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Pretty Urls

  • submit to reddit
        If url is 'index.php/hello' then $request will be 'hello'

$request = $_SERVER['PATH_INFO'];
if (isset($request[0]) && ($request[0] == '/')) {
    $request = substr($request, 1);


p c replied on Mon, 2007/02/19 - 11:09pm

In order to do the 'split' thing: $data = explode("/",$_SERVER['PATH_INFO']); $request = $data[0];

Snippets Manager replied on Mon, 2012/05/07 - 1:12pm

Cool! I don't know PHP, but is there a way you could use a 'split' sort of function to do this automatically?