Hide controller name |
[eluser]Dauntless[/eluser]
Hi, How can I hide the controller name? Fe, I have the site http://www.mydomain.com which has a main controller: 'main'. I don't want the people to have to go to mydomain.com/main/contact (fe), but just mydomain/contact (since 'main' is the controller that represents the main site). I've already hidden the index.php through htaccess. I'm guessing I have to look at the routing options? Any help would be grate Greets!
[eluser]wemago[/eluser]
see the user guide, u'll get everything about routing. u should do something like this Code: $route['NameYouWantUserToSee'] = 'YourController/Function';
[eluser]Dauntless[/eluser]
That would mean that I would have to create a route entry for every method I have. Isn't there a way so that I can say: "If the first segment isn't main or admin, place 'main' in front of segments" ?
[eluser]barbazul[/eluser]
Try this one $route['admin(.*)'] = 'admin$1'; // Anything that starts with 'admin' remains the same $route['(.*)'] = 'main/$1'; // Anything else is redirected to main/..
[eluser]Dauntless[/eluser]
That seems to do a pretty good job, Thanks!! (Although I did have to add one line, so that links with 'main' already in it, stay the same. It's the same as the admin - line, but adjusted for 'main'). What kind of technique is this exactly? Are these regex's ? If not, this technique should be added to the routing-documentation... Thanks!
[eluser]barbazul[/eluser]
jajajaj the "weird" technique is nothing else but a simple regex. URI Routing Although it's documented, It doesn't specify that whatever rules you set must match the ENTIRE uri string since the rule is appended between ^ and $ (begin and end symbols) |
Welcome Guest, Not a member yet? Register Sign In |