Welcome Guest, Not a member yet? Register   Sign In
regex in route.php
#1

[eluser]neph[/eluser]
i'm trying to figure out a way to set up a conditional for not equal to in the route.php file.


$route['!=admin'] = 'home/index';


i have a pretty basic cms that is pulling the actual page markup/content from the database but i want the pages to show up without having to provide a controller name in the url, the only work around i've gotten so far is running a switch in my admin controller for each of those functions and setting a static route for it


so www.site.com/pagename would do a $route[':any'] = "pages/view", works but it causes conflicts with my admin section. so..in short is there a way to do (:any if not equal to 'admin') as part of the regex in the route.php file?
#2

[eluser]xwero[/eluser]
The easiest way to solve it is to put an admin route before all the others
Code:
$route['(admin)(.*)'] = '$1$2';
$route['([a-zA-Z0-9\-\/]+)'] = 'pages/view'
Limit the route to the allowed characters. set the uri_protocol to path_info to prevent the need to add more allowed characters.




Theme © iAndrew 2016 - Forum software by © MyBB