CodeIgniter Forums
Another URL question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Another URL question (/showthread.php?tid=38897)



Another URL question - El Forum - 02-22-2011

[eluser]wintercounter[/eluser]
Sorry folks, i've tried to search the Forum and the Docs, there's probably an answer in the forum to my question, but I even don't know how to search for...

How can i make dynamic segment 1?
Like Wordpress does...
For ex: mysite.com/codeigniter2.0_has_been_relased
Instead of: mysite.com/entry/codeigniter2.0_has_been_relased

Of course, if there's no match, than it should search for other controllers like contact, about_us, etc...

Thanks for your help!


Another URL question - El Forum - 02-22-2011

[eluser]stuffradio[/eluser]
You will want to use routes.

Code:
$route['defaultcontroller/(:any}'] = 'defaultcontroller/index/$1';
You can change the name of defaultcontroller to your default controller, and index to any function in that controller you want to.


Another URL question - El Forum - 02-23-2011

[eluser]wintercounter[/eluser]
Now i have this in the routes file:
Code:
$route['default_controller'] = "front";
$route['default_controller/(:any)'] = 'entry/index/$1';

But this only returns the 404 page:
mysite.com/something


Another URL question - El Forum - 02-23-2011

[eluser]wintercounter[/eluser]
Ok, now figured out, using this way now :

Code:
$route['default_controller'] = "front";
$route['(:any)'] = 'entry/index/$1';
$route['login'] = 'login';

But isn't there any other way, to not route all may URIs and pages?
Should I use a mod_rewrite based solution?