Let me understand how to accomplish the next while using Codigniter MVC framework:

I would like the Web addresses on my small site searching such as this:


So essentially the URI consists of condition / city / article.

I wish to cover all metropolitan areas within the 50 states, however i wouldn't wish to write a controller for every condition and every city.

So my question essentially is:

How do i write just one controller which will display a condition index in line with the first URI segment an additional controller exhibiting a town index in line with the second URI segment?



You should use mod_rewrite in Apache to complete the URL rewrite. Within the document of CodeIgnitor http://codeigniter.com/wiki/mod_rewrite/ . Essentially, you need to define the standard expression to rewrite /arg1/arg2/arg3 to url your_controller/state=arg1&city=arg2&value=arg3 Particulars of mod_rewrite are available at http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

you could do this it by setting up a route inside your config/routes.php

$route['^(:any)/(:any)'] = "some_controller/some_method/$1/$2";

that will map everything in to the some_method purpose of your some_controller class. if you have other things which is not example.com/condition/city it will likewise get sent there.. you would need to route it of there with another route.