Sorry, I was a little bit confused by the wording of your question, but I think I understand what you are trying to talk about.
First: Read the Docs on Controllers. Codeigniter documentation rocks.
Second: The URI's are routed directly to controller class names and their functions.
For example:
<?php
class Profile extends CI_Controller {
function item($username = NULL, $title = NULL)
{
if (is_null($username) || is_null($title)) redirect(base_url());
// blah run code where $username and $title = URI segement
}
}
This will produce this URL:
http://www.example.com/profile/item/username/whatever-i-want
Then you can remove item using routes in application/config/routes.php (docs):
$route['(:any)'] = 'profile/item/$1';
Better way though (read ahead):
$route['profile/(:any)'] = 'profile/item/$1';
Finally, this will create the URL you are looking for:
http://www.example.com/username/whatever-i-want
//http://www.example.com/profile/username/whatever-i-want
I might need to double check this for syntax errors, but it's the basics of how Codeigniter routing works. Once your URL is setup like that, you can do whatever you want to it with your JS.
However, I strongly advise against this method because routing a class like this will pretty much render the rest of the application/site useless, unless this is your only controller/function (probably not the case) you have. I think you would be better off with just having a class name in the URL one way or another.
Alternatively, you could also just use index() and $this->uri->segment() like so if you want to skip the routing in a non-conventional way.
<?php
class Profile extends CI_Controller {
function index()
{
$username = $this->uri->segment(1);
$title = $this->uri->segement(2);
}
}
Hopefully, that makes sense and helps you with your problem.