简体   繁体   中英

CodeIgniter Views

Ok I have adopted a CodeIgniter Setup,

My route.php in config looks like this:

$route['default_controller'] = "development";

My development.php controller looks like this:

class Development extends Controller
{

function Development() {

parent::Controller();

}

public function Index() {

    $this->load->view('index');

}
function show() {

    $this->load->view('show');

}
}

When I go to the root folder, in my browser, it does load the index.php view, I want to make a link to show.php which is also in my Views dir. the URL I'm using is eg: my.server/test/codeigniter/ but when I go to my.server/test/codeigniter/show my show.php doesn't load. Am I doing this correctly?

I should mention I've tried public function show() also and it doesn't work, also I have no .htaccess file in the directory

Any advice would help!

Two rules are enough in your .htaccess file:

# check if the requested resource is not an existing file
RewriteCond %{REQUEST_FILENAME} !-f

# rewrite internally to index.php
RewriteRule ^(.*)$ index.php [QSA,L]

Mod_rewrite and AllowOverride All assumed enabled.

Ken Struys comment on your question is correct. The default controller status you give a controller means that controller and the index function will load if you go to my.server/test .

Other than that, you need to include index.php/controller_name/function_name to get to your controller functions.

Unless that is, you implement some fancy .htaccess url rewriting, which I can't help you with.

You can set it in routes.php as below:

$route['show']='development/show';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM