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:
$rout['(: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";
Categories: Web Development
Tags: codeigniter, php
3 Comments
Kenny
thank you so much
March 31st 2010
madmarker
thank you thank you thank you!!
P.S.: it’s definitely should be in CI User Guide…
June 2nd 2010
r0n9
$route[’^((?!controller|controller|controller)\S*)’] = “article/$1”;
July 1st 2009