Question

I have the url: http://devsite.com/page/profile/11

I would like to retain the current functionality of /controller_name/method/profile_id

BUT, I would like the url to drop the controller name, so it would just be: method/profile_id

I'm thinking this is not what codeigniter uri routing is meant for. I understand to a degree and use uri routing all the time, but it seems that this is more of something I'd need to do with apache mod_rewrite or something? Any ideas are appreciated.

Thanks.

Was it helpful?

Solution

Small bug in your route. There shoud be $1 at the end, not $2:

$route['profile/(:any)'] = 'page/profile/$1';

OTHER TIPS

I figured it out, I wasn't thinking about it correctly. I have not BUILT the application yet, rather I'm building it as we speak. So if I HAD built the entire application and I was just now asking this, it would indeed be an apache rewrite situation, but since I am building the app now, some "pre-thought" will save me the trouble.

Instead of linking to 'page/profile/id', I can just link to 'profile/id' and then in my routes.php put this:

$route['profile/(:any)'] = 'page/profile/$2';
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top