GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Saturday, April 16, 2011

Apache - Building Pretty URL

<?php
    $q = $_SERVER['REQUEST_URI'];
    $queries = explode('/',$q);  // the url: /index.php/hello/somevalue/somevalue
    var_dump($queries);
    $page = $queries[2];
    $value1 = $queries[3];
    $value2 = $queries[4];
    if($page == 'holla'){
        include "holla.php";
    }else if($page == 'hello'){
        include "hello.php";
    }else if($page == '' && $queries[1] = 'index.php'){
        include "front.php";
    }else{
        include "404.php";
    }
?>

And the htaccess file is like this one:
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule .* index.php [L]
Share/Bookmark

No comments:

Post a Comment