Saturday, June 19, 2010

Codeigniter Route Everything, except these Controllers

another Codeigniter routes, Codeigniter Route Everything, except these Controllers

There was a recent post on the codeigniter forums trying to get urls like these:
http://yoursite.com/your-slug
This problem could have been easily resolved using this route:
$route['(:any)'] = 'articles/$1';

In this route, all characters after the domain will be passed to the controller, 'article'.

However, the problem was he also had some controllers that he didn't want to use the route for. A quick fix for the route was to use a 'simple' regex using negative lookahead
$route['^(?!controller|controller|controller)\S*'] = "article/$1";


p/s:original post from here

No comments:

Post a Comment