php - codeigniter handle code when application controller directory get accessed -
my directory settings
-- application -- controllers -- admin -- manage
when accessed 'localhost/admin', redirect 'localhost/'.
question :
- should handle ? want when accessed 'localhost/admin' , not redirect them 'localhost/'.
thx
so it's 3 part answer.
you need controller named (in example) example.php
. need view in view folder called example_view.php
. , need edit config/routes file.
first, create controller in admin folder. in case i'll call example.php. should this:
<?php if ( ! defined('basepath')) exit('no direct script access allowed'); class example extends ci_controller { /* | ------------------------------------------------------------------- | class constructor function | ------------------------------------------------------------------- */ public function __construct() { parent::__construct(); } /* | ------------------------------------------------------------------- | view index launching page | ------------------------------------------------------------------- */ public function index() { $this->load->view('example_view'); } }//end controller class /* end of file example.php */ /* location: ./application/controllers/admin/example.php */
second create view called example_view.php
, put in view folder.
third open config/routes.php
, add line: $route['admin'] = "admin/example";
this last part points called localhost/admin
view indicated in example.php
index()
function.
Comments
Post a Comment