VlTr
VlTr

Reputation: 55

URI routing in CodeIgniter

This link works site.tv/admin/edit/ (controllers/admin/edit.php), but this doesn't work site.tv/admin/reg/edit/ (controllers/admin/reg/edit.php) Is it too long path to controller?

Upvotes: 2

Views: 494

Answers (2)

afarazit
afarazit

Reputation: 4984

Your routing should be index.php/CLASS/METHOD/ID

Quote from application/config/routes.php

Typically there is a one-to-one relationship between a URL string and its corresponding controller class/method. The segments in a URL normally follow this pattern:

example.com/class/method/id/

for example

class test extends CI_Controller{

    public function hello() {
        echo 'hello world';
    }

    public function meep() {
        echo 'meeeeeep';
    }

    public function param($value){
            echo 'Your parameter is '. $value;
    }
}

Then your url should be index.php/test/hello, index.php/test/meep and index.php/test/param/whataeverhere

UPDATE:

If you need "multiple packages" create subdirectories for your "packages" like in

controllers
    ->admin
           ->reg
                ->myfile.php
                ->myfile2.php
           ->reg2
                ->myfile.php
                ->myfile2.php

and then create your custom routes in routes.php under application/config/ folder

Upvotes: 5

red eyes dev
red eyes dev

Reputation: 398

I think it's a problem to CHMOD. check if reg fils it's readeable.

Upvotes: -1

Related Questions