On many web sites, there is a contact page, about us page, and other pages at the root level, ie mydomain.com/about/ or mydomain.com/about.php. With CodeIgniter, the first URI segment, assuming you're using the mode_rewrite, is supposed to be the name of the controller, and the second segment is the name of the function. I didn't want to have the name of my controller in the URL for these root level pages. I think the "main", or whatever controller name I might later choose, in overfood.com/main/about/ makes the URL longer than it needs to be. It's almost as ugly as when I see people have "html" in their URL, which is often the case when people use content management systems or some sort of template
With the help of the people on the CodeIgniter forums, I found the solution to my problem. It's not really a problem, but rather a preference, I suppose. I knew part of the solution was to use the "routes.php" file, but I wasn't using it with all the right parameters. The obvious parameter was the "default_controller", which I set to "main". What I was missing was individual settings for each root level page. Since I have an "about us" page, I needed a setting for that. I also needed a setting for the "contact us" page. With just these two extra lines, I was able to accomplish what I needed.
So, now my routes.php file looks like ...
$route['default_controller'] = "main"; $route['scaffolding_trigger'] = "I_would_be_dumb_to_leave_this_here"; $route['about'] = 'main/about'; $route['contactus'] = 'main/contactus';
Just as a side note, it got a little more complicated when trying to send messages with the contact page. I didn't want to add another line to my routes page for the "page" that handles the emailing of the message. So, I used "/contactus/send_message" as the action of my form. This made my "contactus" function a little longer since it now has to handle displaying a blank form, validating the form data, and whatever happens as a result of that, which would be sending the email or redisplaying the form with a proper error message.
The solution here was just to do some if/then checking of the "$this->uri->segment(2)" variable. I'd rather go this route than have to manage another view file and adding another line to the routes.php file. Not too bad.

