Welcome Guest, Not a member yet? Register   Sign In
Routes - setting exceptions for :any
#1

[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 Smile but if anyone understands what i'm trying to do, it would be good to hear from ya.
#2

[eluser]Michael Wales[/eluser]
Code:
$route['blog'] = 'blog';
$route['news'] = 'news';
$route[':any'] = 'default';

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.
#3

[eluser]Subey[/eluser]
[quote author="walesmd" date="1191400533"]
Code:
$route['blog'] = 'blog';
$route['news'] = 'news';
$route[':any'] = 'default';

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
#4

[eluser]Alex007[/eluser]
Try this:
Code:
Routes.php:

/* CI specific routes */
$route['default_controller'] = "go";
$route['scaffolding_trigger'] = "";

/* Auth routes */
$route['auth/:any'] = "auth/$1";
$route['auth'] = "auth";

/* All other routes */
$route[':any'] = "go";
#5

[eluser]Subey[/eluser]
Work it:

$route['auth/:any'] = "auth";

What difference is beetwen:

$route['auth/:any'] = "auth/$1"; a $route['auth/:any'] = "auth"; ??




Theme © iAndrew 2016 - Forum software by © MyBB