CodeIgniter URI routing (dynamic, multilingual)
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.
If you can see the routing is working correclty, try using $this->uri->segment(n)
instead? Where n is the number of the segment you are getting from the URI, i.e. http://site.com/1/2/3/4/...
I have seen problems using the implicit parameters of methods like you are using.
For more information, see the CodeIgniter User Guide - the URI Class here:
http://codeigniter.com/user_guide/libraries/uri.html
Best of luck.
精彩评论