• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
route any to a controller

#1
[eluser]Unknown[/eluser]
Hi everyone,

I'm trying to make a route to get that :

any/thing/etc to site/any/thing/etc ( where site is a controller from a HMVC module )

I tried some stuff like :

Code:
$route[':any'] = "site/$1";

I can't get that working... and i can't do that using a htaccess, need to do that inside CI

Anybody can help me ?

Thanks a lot


#2
[eluser]bralens[/eluser]
not an expert but shouldn't it be something like
Code:
$route['(:any)'] = "site/$1";
?

#3
[eluser]Unknown[/eluser]
Yes it works thank you.

It didn't work because it's overriden by the default controller.

Example : if i write :

Code:
$route['default_controller'] = "welcome";
$route['(:any)'] = "site/$1";

example.com/ displays the welcome controller but example.com/method displays site/method (good).

So i had to define $route['default_controller']="site" too and it works.

#4
[eluser]InsiteFX[/eluser]
Code:
/* ------------------------------------------------------------------------
* DO NOT! REMOVE THIS LINE: This needs to be the very last route in the file.
* ------------------------------------------------------------------------
*/
$route['(.*)'] = 'site/$1';

This can also be used with _remap


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.