Welcome Guest, Not a member yet? Register   Sign In
Routing Problem
#1

[eluser]Aidy[/eluser]
I have a route setup like

Code:
$route['Resource-Centre/Catalogue/(:any)/(:any)/(:any)/(:any)/(:any)/(:any)/(:any)/(:num)/(:num)'] = 'resource-centre/catalogue/$1/$2/$3/$4/$5/$6/$7/$8/$9';

The last two wildcards are for pagination (I'm using the digg style pagination library).

This works fine on our test server setup but on the live site it's throwing a 404 if their are no pagination values. It works fine if their are.

Can anyone help please.
#2

[eluser]n0xie[/eluser]
It's because it expects to find 2 more arguments that are of type 'num'. If there aren't any arguments, the rule isn't executed.

Why not just do
Code:
$route['Resource-Centre/Catalogue/(:any)'] = 'resource-centre/catalogue/$1';
and check for paging variables inside your method?
#3

[eluser]mddd[/eluser]
Logical. If the last two items are not numbers, the route does not match. If you want to match the route even if there are no numbers at the end, you need to change the route so it still matches without the numbers.
In this case, I would suggest making the route simply
Code:
$route['Resource-Centre/Catalogue(.*)'] = 'resource-centre/catalogue$1';
and then checking in the controller (for instance in the constructor method) which information is requested exactly.
Or if you make your urls all lowercase, you wouldn't even need the route.

Edit:Exactly what n0xie said.
#4

[eluser]Aidy[/eluser]
Thank you n0xie and mddd.

That's working now and all makes sense now!




Theme © iAndrew 2016 - Forum software by © MyBB