CodeIgniter Forums

Full Version: Codeigniter URL Pattern using htaccess / route / model
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've just put my hands on MVC and new to Codeigniter.

As per my understanding Codeigniter url consist of (base url) / Class / Method

I am trying some more complex url structure as
which I presume can be achieved by calling another controller from another, or may be using route.

PS, category/country/state/city here changes dynamically based on product.

Is it possible to have url like that with Codeigniter or do I have to stick with ?
Thanks you.
Yes, you can have an URL like that. How is up to you.

An option is to use the _remap method

Add this to your controller
PHP Code:
public function _remap($method) {
   // $method = typically the second segment of the URI
   if ($method === 'some_method') {
   } else {

What this does is override the default behavior of how CI calls methods. When this method is available within the called controller this is the first method called.
From here you can route to any other method within the called controller.

If you want controllers calling controllers how should look into HMVC
But if you are new to MVC and CI I would advise getting to know the basics first.

Hope this helps you on your way