...

View Full Version : Rooting Or Indexing



hmvrulz
05-18-2008, 07:12 AM
Which is the best way to create a rooting or indexing system.

i.e forum/posts/22
by going to this url how to display the 22 id post

and by going to forum/posts/22/edit
go to editing the 22nd post.

the method i have come across is as follows

.htaccess in the root directory


RewriteEngine On
RewriteRule !(\.gif|\.png|\.jpe?g|\.css|\.js|\.php|^public/.*)$ index.php [nocase,last]




index.hp also in the root directory using the following method


// Requested URL
$url = $_SERVER['REQUEST_URI'];

// Removes Apllication root from url
$url = str_replace('/tumblelog/', '', $url);


//posts/2/edit

$routes = array(
array('url' => '/^posts\/(?P<id>\d+)$/', 'controller' => 'posts', 'view' => 'show'),
array('url' => '/^posts\/(?P<id>\d+)\/edit$/', 'controller' => 'posts', 'view' => 'edit')
);


$params = array();

$route_match = false;

foreach($routes as $urls => $route)
{
if(preg_match($route['url'], $url, $matches))
{
$params = array_merge($params, $matches);
$route_match = true;
break;
}
}

if(!$route_match) { exit('no route found'); }

//print('controller: '.$route['controller'].' view:'.$route['view'].' id:'.$params['id']);

//echo $url;

include($_SERVER['DOCUMENT_ROOT'].'tumblelog/controllers/'.$route['controller'].'.php');


CAN some one tell me if this is the correct method else direct me to the right resouces



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum