CodeIgniter URI routing (dynamic, multilingual)

Posted by koteko on Stack Overflow See other posts from Stack Overflow or by koteko
Published on 2010-05-06T14:24:12Z Indexed on 2010/05/06 14:28 UTC
Read the original article Hit count: 174

Filed under:
|
|

I'm trying to redirect all routs to one main controller. Here is my routes.php

$route['default_controller'] = "main";
$route['scaffolding_trigger'] = "";

//$route['(\w{2})/(.*)'] = '$2';
//$route['(\w{2})'] = $route['default_controller'];

$route['(en|ge)/(:any)'] = $route['default_controller']."/index/$1";
$route['(:any)'] = $route['default_controller']."/index/$1";

I need language id to be passed with every link (like: http://site.com/en/hello-world)

Here is my main controller:

class Main extends Controller
{
    function __construct()
    {
        parent::Controller();       
    }

    function index($page_type=false, $param=false) 
    {
        die($page_type.' | '.$param.'| Aaa!');  
    }
} 

I want to check if predefined file type exists (like: http://site.com/en/archive/05-06-2010 - here predefined type would be archive) then do something. If not then search in the database for slug. If not found then go to 404.

The problem is that I can't get index function parameters ($page_type, $param). Thanks for help.

© Stack Overflow or respective owner

Related posts about codeigniter

Related posts about routing