路线不在Codeigniter中工作

I'm using CodeIgniter 1.9 to build a website.

I want http://myurl.com/index.php/user/profile/2 to take me to the Profile Page for the user with the id of 2.

My routes.php file looks like this.

$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['user/profile/(:num)'] = 'user/profile_view/$1';

My user.php file looks like this.

class User extends CI_Controller {

    function __construct()
    {
        parent::__construct();
        $this->load->model('user_model');
    }

    function profile_view($id)
    {
            $data = array();
        log_message("info", "I am in the profile_view method of user.php.");

        $this->load->view("templates/header", $data);
        $this->load->view("templates/footer", $data);
    }
}

The code is never making it to the log_message() function and it is throwing a 500 error that says exactly this...

HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfil the request.

Any help would be greatly appreciated. I've been looking for several hours now with no luck.

The $data you pass is not initialize. Probably your error 500 comes from it. Before log_message, type this statement:

$data = array();

Tell us if you have an error after this correction.

I think your routing might be slightly off. Try this out:

$route['user/profile'] = 'user/profile_view';

Your User Controller should be able to see the incoming parameter from the URL just fine.

Thanks for those you pointed out the PHP error log. It was a problem in my Model code. I apparently hadn't completely made the mental switch from one language to the next and I had put...

$return_array = [];

... as my array initialization there. The PHP log got me pointed in the right direction.

Thanks for the help everyone.