Php – CodeIgniter: Page not found when passing parameters to a controller

codeignitercodeigniter-urlhttp-status-code-404PHP

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: http://codeigniter.com/user_guide/general/controllers.html#passinguri

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.

Best Answer

With that URL, CodeIgniter can't understand if you want to pass 123 to the index method or if you're requesting the 123 method with no parameters. You have to explicitly name the default method if you need to pass it some parameters.

http://mysite/index/123
Related Topic