Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter: Page not found when passing parameters to a controller?

I'm trying to pass parameters to a control in codeigniter, but I'm getting 404 page not found error, I don't get it, I did what the guide says: https://www.codeigniter.com/user_guide/general/controllers.html#passing-uri-segments-to-your-methods

When I remove the params in the index function and just access the controller everything works fine, but I can't pass a value to it...

Here is the code the way I'm trying to send a param: http://mysite/123

<?php
class Main extends Controller {

    function index($username) {

        echo $username;

    }

}
?>

How can I get more info regarding this error from codeigniter?

Thank you.

like image 428
Maulik patel Avatar asked Aug 09 '11 15:08

Maulik patel


1 Answers

The URL needs to be http://mysite/Main/index/123.

CodeIgniter URLs are http://<url>/<Controller>/<Method>/<params>.

like image 139
Rocket Hazmat Avatar answered Nov 11 '22 10:11

Rocket Hazmat