02-11-2011, 05:46 AM
[eluser]mmackay[/eluser]
It's been one of those weeks and this has been bugging me for a couple of days now. I could just be having a bad week and not spotting the obvious but my routing isn't working as intended. It worked perfectly on v.1.7.3 but when I upgraded to 2.0 it kinda went wrong. Here's the low down...
This is my .htaccess file:
The idea being that I'm capturing the following URLs:
http://www.domain.com/username/audio/audio-item-token <-- Displays the users audio
http://www.domain.com/username/video/video-item-token <-- Displays the users videos
http://www.domain.com/username <-- Displays all the users items
My CI routing file is as follows:
The main $route['(:any)'] = 'user/index'; actually sits at the bottom of the routes file.
I'm then using the uri_segment (temporarily) to retrieve the username, validate etc. etc. However, this just simply doesn't work. I'm getting a CI 404 returned for any URL. Strangely though, it works for the users admin URL:
The admin rules appear below the other routes.
I don't get how the admin rules work but the main site ones don't?
A quick view of the log (when calling http://www.domain.com/mikemackay for example) shows as:
DEBUG - 2011-02-11 11:40:43 --> Config Class Initialized
DEBUG - 2011-02-11 11:40:43 --> Hooks Class Initialized
DEBUG - 2011-02-11 11:40:43 --> Utf8 Class Initialized
DEBUG - 2011-02-11 11:40:43 --> UTF-8 Support Enabled
DEBUG - 2011-02-11 11:40:43 --> URI Class Initialized
DEBUG - 2011-02-11 11:40:43 --> Router Class Initialized
ERROR - 2011-02-11 11:40:43 --> 404 Page Not Found --> mikemackay
I'm stumped. Anyone got any ideas? Can you spot something simple that I'm overlooking?
- Mike
It's been one of those weeks and this has been bugging me for a couple of days now. I could just be having a bad week and not spotting the obvious but my routing isn't working as intended. It worked perfectly on v.1.7.3 but when I upgraded to 2.0 it kinda went wrong. Here's the low down...
This is my .htaccess file:
Code:
RewriteRule ^([a-z0-9]+)/audio/([a-z0-9\-]+)(/?)$ index.php/$1/tracks/$2 [L,NC]
RewriteRule ^([a-z0-9]+)/video/([a-z0-9\-]+)(/?)$ index.php/$1/mixes/$2 [L,NC]
RewriteRule ^([a-z0-9]+)(/?)$ index.php/user [L,NC]
The idea being that I'm capturing the following URLs:
http://www.domain.com/username/audio/audio-item-token <-- Displays the users audio
http://www.domain.com/username/video/video-item-token <-- Displays the users videos
http://www.domain.com/username <-- Displays all the users items
My CI routing file is as follows:
Code:
$route['(:any)/tracks/(:any)'] = 'user/tracks';
$route['(:any)/mixes/(:any)'] = 'user/mixes';
$route['(:any)'] = 'user/index';
The main $route['(:any)'] = 'user/index'; actually sits at the bottom of the routes file.
I'm then using the uri_segment (temporarily) to retrieve the username, validate etc. etc. However, this just simply doesn't work. I'm getting a CI 404 returned for any URL. Strangely though, it works for the users admin URL:
Code:
RewriteRule ^([a-z0-9]+)/admin(/?)$ index.php/$1/admin [L,NC]
RewriteRule ^([a-z0-9]+)/admin/(audio|video)(/?)$ index.php/$1/admin/$2 [L,NC]
Code:
$route['(:any)/admin'] = 'admin';
$route['(:any)/admin/audio'] = 'admin/audio';
$route['(:any)/admin/video'] = 'admin/video';
The admin rules appear below the other routes.
I don't get how the admin rules work but the main site ones don't?
A quick view of the log (when calling http://www.domain.com/mikemackay for example) shows as:
DEBUG - 2011-02-11 11:40:43 --> Config Class Initialized
DEBUG - 2011-02-11 11:40:43 --> Hooks Class Initialized
DEBUG - 2011-02-11 11:40:43 --> Utf8 Class Initialized
DEBUG - 2011-02-11 11:40:43 --> UTF-8 Support Enabled
DEBUG - 2011-02-11 11:40:43 --> URI Class Initialized
DEBUG - 2011-02-11 11:40:43 --> Router Class Initialized
ERROR - 2011-02-11 11:40:43 --> 404 Page Not Found --> mikemackay
I'm stumped. Anyone got any ideas? Can you spot something simple that I'm overlooking?
- Mike