CodeIgniter Forums
Question about monolithic controllers and URL formatting - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Question about monolithic controllers and URL formatting (/showthread.php?tid=24419)



Question about monolithic controllers and URL formatting - El Forum - 11-09-2009

[eluser]Mr.Mo[/eluser]
Hello All,

I'm new here, so my apologies in advance if this is a dumb question.

I would like to use CI on some small web sites (5-10 "pages").

It would work into my workflow very well if I could use a single controller for the majority of the pages. But I do not want to sacrifice simple URL's to do this.

Is there a way that a singles controller could handle URL's like:

site.com/
site.com/about-us
site.com/products
site.com/contact-us

while another controller takes care of forms processing

site.com/forms/submit
site.com/forms/ajax


What would be the most graceful way to do this ?

Much Thanks,
Mr.Moe


Question about monolithic controllers and URL formatting - El Forum - 11-09-2009

[eluser]Ben Edmunds[/eluser]
For a basic site that would be fine.

Look up routes in the userguide. That will give you pretty urls with the functionality you want.


Question about monolithic controllers and URL formatting - El Forum - 11-09-2009

[eluser]Mr.Mo[/eluser]
Thanks Ben,

I've tried doing this using a wildcard route, but it doesn't seem to work. The route I tried looked like this:

$route[':any'] = "master/$1";


I would like to avoid having to manually enter all of the function names a second time (1st in the controller, and then here) as it seems like it would be an easy place for things to get out of sync.

Thank you for your help, I am liking CI and the community here very much!

-Mr.Moe


Question about monolithic controllers and URL formatting - El Forum - 11-09-2009

[eluser]Mr.Mo[/eluser]
Woops, my bad, I should have been using:

$route[’(:any)’] = “master/$1”;