Skip to content

Instantly share code, notes, and snippets.

@wilburhimself
Created November 28, 2010 17:04
Show Gist options
  • Select an option

  • Save wilburhimself/719095 to your computer and use it in GitHub Desktop.

Select an option

Save wilburhimself/719095 to your computer and use it in GitHub Desktop.
Page controller básico
RewriteEngine on
RewriteCond $1 !^(index\.php|favicon.ico|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
<?php
function index() {
include 'views/about.php';
}
?>
<?php
require_once 'header.php';
// La lógica del page controller aquí
require_once 'footer.php';
?>
<?php
$query = $_SERVER['QUERY_STRING'];
$request = explode('/', $query);
$controller = (!empty($request[1])) ? $request[1] : 'home';
$action = (!empty($request[2])) ? $request[2] : 'index';
$parameter = (!empty($request[3])) ? $request[3] : null ;
include 'controllers/'.$controller.'.php';
call_user_func($action, $parameter);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment