| 
<?php// make sure you have a .htaccess file that points to this file for 404 errors use something like this:
 //
 // ErrorDocument 404 ctr.php
 //
 // it isn'T wrong to catch 401 and 403 errors, too
 
 
 include("rewriter.class.php");
 
 // create rewriter instance use the names set in the class script
 $controller = new rewriter();
 // parsing the incomming request to the REQUEST array
 $REQUEST = $controller->decode($REQUEST_URI);
 //tell the clinet that everything is ok and the file was found!
 $controller->ok();
 
 // display result for understanding
 echo "<pre>";
 print_r($REQUEST);
 echo "</pre>";
 
 // now see what happend:
 switch($REQUEST['page']) {
 // the URI http://localhost/rewriter/first.html moved to one of these results...
 
 case "first" :
 // so this is the page, that is displayed if there is first.html given...
 echo "First page called"; echo "<br><a href=\"".$controller->encode(array("second"),".html")."\">second</a>";
 break;
 case "second" : echo "Second page called"; echo "<br><a href=\"".$controller->encode(array("third"),".html")."\">third</a>";break;
 case "third" : echo "Third page called"; echo "<br><a href=\"".$controller->encode(array("index"),".html")."\">index</a>";break;
 
 default :
 // this page is called if there is no 'file' given
 echo "Default page called"; echo "<br><a href=\"".$controller->encode(array("first"),".html")."\">first</a>";
 break;
 
 }
 
 
 ?>
 |