Routes - setting exceptions for :any |
[eluser]Unknown[/eluser]
is there a way for codeignitor to set exceptions for the ':any' wild card? what i am trying achieve is, if any url is entered it defaults to a particular controller, but if the url contains a reference to a defined controller then it load that controller eg: $route[ :any NOT blog|news|etc ] = "default"; i've tried using a regular expression $route['([a-zA-Z-]*)'] = "default"; which works and doesn't interfere with my other controllers, but this will only work if there is only 1 uri segment but i am also trying to create the illusion of subpages eg: localhost/about-us/ eg: localhost/about-us/company/ using the reg ex above the only way to get to the 'company' content is localhost/company (my default controller just takes the last uri segment and find content from the database) probably not makin any sense but if anyone understands what i'm trying to do, it would be good to hear from ya.
[eluser]Michael Wales[/eluser]
Code: $route['blog'] = 'blog'; Routes are run from top to bottom - so CI will use the first route that matches. Since your :any route is the first that would match 'about-us' it's the one to get used.
[eluser]Subey[/eluser]
[quote author="walesmd" date="1191400533"] Code: $route['blog'] = 'blog'; Routes are run from top to bottom - so CI will use the first route that matches. Since your :any route is the first that would match 'about-us' it's the one to get used.[/quote] i have: $route['default_controller'] = "go"; $route['scaffolding_trigger'] = ""; $route['auth'] = "auth"; $route[':any'] = "go"; when i go on www.domain.com/auth - work, but www.domain.com/auth/login - don't work Thx for reply
[eluser]Alex007[/eluser]
Try this: Code: Routes.php:
[eluser]Subey[/eluser]
Work it: $route['auth/:any'] = "auth"; What difference is beetwen: $route['auth/:any'] = "auth/$1"; a $route['auth/:any'] = "auth"; ?? |
Welcome Guest, Not a member yet? Register Sign In |