Do you want to implement your own search friendly url engine? Limeware has its own URL rewrite engine which is not dependent on Apache mod_rewrite. It is relatively easy to implement in other systems or to adapt to your specs.This is an evil url: www.notfriendly.com/index.php?menuID=28&type=articleThis is a good url: www.friendly.com/index/menuID_28-type_articleMy solution in Limeware CMS is to do the URL processing in PHP. If you follow these steps you will have your own Apache compatible URL rewrite engine in no time.Step 1.In your .htaccess file (If you don't have one, then create a new one in the folder where your index.php resides) add the following:
// constructs search friendly urls and create correct url paths for links and imagesclass UrlFilter { var $origUrl; var $numOfItems; var $itemsMap; function UrlFilter() { $this->processURI(); $this->constructBaseUrl(); } function processURI() { $array = explode("index", $_SERVER['PHP_SELF']); $newUrl = str_replace("/", "", $array[count($array)-1]); $array = explode("-", $newUrl); $num = count($array); $this->numOfItems = $num; $url_array = array(); $items = explode("-", $newUrl); $num = count($items); for ($i = 0 ; $i < $num ; $i++) { $item = explode("_", $items[$i]); $this->itemsMap[$item[0]] = $item[1] ; } } function constructBaseUrl() { // need to construct the original url $array = explode("index", $_SERVER['PHP_SELF']); $num = count($array); $this->origUrl = ""; for ($i = 0; $i < $num-1 ; $i++) { $this->origUrl = $this->origUrl . $array[$i]; } } function getItem($key) { if (array_key_exists($key, $this->itemsMap)) { return $this->itemsMap[$key]; } else { return null; } } function getOriginalUrl() { return $this->origUrl . "index"; } function getBaseUrl() { return $this->origUrl; }}
Nessun commento:
Posta un commento