3

I'm new in codeigniter I have problem

I use my OS X Lion, and I use .htaccess I can call directly localhost/site_folder/ it works like charm, but I have second function in my controller but I can't directly call that function like this localhost/site_folder/function2

here my controller

class My_site extends CI_Controller {
function __construct() {
  parent::__construct();
  }
function index() {
  --some script--
  }
function function2() {
  --some script--
  }
}

and it's says url not found, why?

thank you

ranggadablues
  • 249
  • 1
  • 4
  • 14

4 Answers4

1
  It may be the issue please Check the uri protocol in the config file that should be AUTO.

  Config/config.php ===> $config['uri_protocol']    = 'AUTO';
vinod
  • 2,850
  • 1
  • 18
  • 23
1

The default routing scheme is example.com/class/function/id/ Doc

If site_folder is the folder where you have installed codeigniter, Your url to function2 would be,

http://localhost/site_folder/my_site/function2
Shiplu Mokaddim
  • 56,364
  • 17
  • 141
  • 187
  • I still cannot access.. here for my .htaccess `RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index\.php|images|robots\.txt|css) RewriteRule ^(.*)$ index.php/$1 [L]` it is right? – ranggadablues Apr 02 '12 at 13:16
1

I found the solutions on this forum http://ellislab.com/forums/viewthread/210578/

Gergo Erdosi
  • 40,904
  • 21
  • 118
  • 94
ranggadablues
  • 249
  • 1
  • 4
  • 14
0

According to Mushi codeigniter automatically adds index.php to your 'localhost/site_folder/' which is specified in the config.php file (line 38). So to call the function you would have to go to 'localhost/site_folder/index.php/function2'

Lazarus-CG
  • 76
  • 7