Welcome Guest, Not a member yet? Register   Sign In
upgraded from 3.0.1 to 3.0.2 , routes problem
#1

(This post was last modified: 10-10-2015, 06:14 AM by AminTheGreat.)

Hi, i have a problem with my custom routes !

my routes codes works fine in CI3.0.1 but after upgrading to CI3.0.2, it just shows 404 for my custom routes !
my .htaccess is works fine and correctly, since i just uploaded app/config/constants.php file and system/ folder to my host ( as mentioned in documentation of upgrading )

does anyone know, what cause the problem ?!

url: http://www.akhyani.net <-- Default Controller works fine
url: http://www.akhyani.net/admin <-- uses routes , shows 404
url: http://www.akhyani.net/admin/index <-- works fine O.o !

my route codes:
Code:
$route['default_controller'] = 'ctrl_main';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

$route['admin'] = 'ctrl_admin';
$route['admin/(:any)'] = 'Ctrl_admin/$1';
$route['admin/(:any)/(:num)'] = 'Ctrl_admin/$1/$2';
Reply
#2

I'm having the same issue.

$route['recurring_pmt_processing'] = 'recurring_pmt_processing/process_recurring_pmt';

Called in CLI:
php index.php recurring_pmt_processing

ERROR: Not Found

The controller/method pair you requested was not found.

This was working fine before the upgrade to 3.0.2
Reply
#3

I'd guess these are not *all* of your routes and/or in the same particular order that you've actually defined them. That makes a difference.
Reply
#4

(This post was last modified: 10-10-2015, 03:03 PM by ogomez.)

$route['terms-of-use'] = 'terms';
$route['privacy-policy'] = 'privacy';
$route['contact-us'] = 'gq/contact_us';
$route['demo'] = 'gq/demo';
$route['(.+)'] = "gq/account/$1/$2";
$route['(.+)'] = "gq/account/$1";
$route['recur_pmt_process'] = 'recur_pmt_proces/process_recur_pmt';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

After reading your response I modified the order to the following:

$route['terms-of-use'] = 'terms';
$route['privacy-policy'] = 'privacy';
$route['contact-us'] = 'gq/contact_us';
$route['demo'] = 'gq/demo';
$route['recur_pmt_process'] = 'recur_pmt_process/process_recur_pmt';
$route['(.+)'] = "gq/account/$1/$2";
$route['(.+)'] = "gq/account/$1";
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

It's now working.

Thanks!
Reply
#5

(10-10-2015, 01:30 PM)Narf Wrote: I'd guess these are not *all* of your routes and/or in the same particular order that you've actually defined them. That makes a difference.

hmmm... well, OK then, these are all my routes with the defined order:
Do you have any suggestions on these ?

Code:
$route['default_controller'] = 'ctrl_main';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

$route['(:any)'] = 'ctrl_main/$1';
$route['main'] = 'ctrl_main';
$route['main/(:any)'] = 'ctrl_main/$1';
$route['main/(:any)/(:num)'] = 'ctrl_main/$1/$2';
$route['main/(:any)/(:any)/(:num)'] = 'ctrl_main/$1/$2/$3';
$route['main/(:any)/(:any)'] = 'ctrl_main/$1/$2';
$route['main/(:any)/(:any)/(:any)/(:num)'] = 'ctrl_main/$1/$2/$3/$4';

$route['admin'] = 'ctrl_admin';
$route['admin/(:any)'] = 'Ctrl_admin/$1';
$route['admin/(:any)/(:num)'] = 'Ctrl_admin/$1/$2';
Reply
#6

Yep ... routes are matched in the order they are defined and your '(:any)' route takes precedence. ogomez got it.
Reply
#7

(:any) routes should always be placed last in your routes.php file

And like Narf stated they work in the order they are defined.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#8

(10-12-2015, 04:18 AM)InsiteFX Wrote: (:any) routes should always be placed last in your routes.php file

And like Narf stated they work in the order they are defined.

Thanks to you anf Narf, my problem has been solved by your solutions.
I wonder why that code was working properly in CI301
Reply
#9

(10-12-2015, 05:44 AM)AminTheGreat Wrote:
(10-12-2015, 04:18 AM)InsiteFX Wrote: (:any) routes should always be placed last in your routes.php file

And like Narf stated they work in the order they are defined.

Thanks to you anf Narf, my problem has been solved by your solutions.
I wonder why that code was working properly in CI301

Because there was a short-circuit condition that checked for literal (non-regexp) matches first. It was removed because with new features added to the router, it increased code complexity and made it hard to maintain.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB