You could pass the uri segments as parameters to your controller.
http://YOUR_URL.com/index.php/city/get/zurich
<?php
class City extends CI_Controller {
public function get($city)
{
echo $city;
}
}
http://www.codeigniter.com/user_guide/general/controllers.html#passing-uri-segments-to-your-methods
Edit
Just to give you an idea:
First remove the index.php from the URL:
create the .htaccess
file
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# When CI is in a subfolder use this line instead
#RewriteRule ^(.*)$ /ci/index.php/$1 [L,QSA]
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Open the file /application/config/config.php
and search for the line
$config['index_page'] = 'index.php';
and change it to
$config['index_page'] = '';
Open the file /application/config/routes.php
and add this line to the other rules
$route['(:any)/(:any)/(:any)'] = "$2/$3/$1";
And the controller looks like this.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class City extends CI_Controller {
public function index($city)
{
echo $city;
}
}
So I'm just changing the order of the segments. 2 = Class, 3 = Method, 1 = parameters.