• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help about path

#1
My CI project
127.0.0.1/CI
The path is CI/
When URL 127.0.0.1/CI /show/1
The path is CI/show
but I want it still CI/

routes.php
$route['default_controller'] = 'welcome';
$route['wish/(:num)'] = 'welcome/wish/$1';

Welcome.php
class Welcome extends CI_Controller {
public function index()
{
$this->load->view('index.html');
}
public function show($a){
$this->load->helper('url');
$data['title'] = 'help';
$data['id'] = $a;
$this->load->view('page',$data);
}
}
Reply

#2
Please, put your code inside code blocks and indent it properly, like this:
PHP Code:
public function index()
{
 
  $this->load->view('index.html');


It's not clear what you want. If you let your users access a URL CI/1, how would your application know which controller/method to call?
I'm not sure whether this route will work:
PHP Code:
$route[':num'] = 'welcome/show/$1'
You can also use regular expressions in routes, for more flexibilty.

Remember that routes are always relative to the base_url.
How is your base_url() set in application/config/config.php?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.