codeigniter and its uri protocol

2019-02-20 20:45发布

问题:

heres some code- when i change

$config['uri_protocol']  = "AUTO";

to

$config['uri_protocol']  = "PATH_INFO";

My controllers all default to the default controller.. hence domain.com/admin defaults to domain.com and domain.com/users defaults to the default controller

where am i going wrong?

回答1:

Is $_SERVER['PATH_INFO'] or getenv('PATH_INFO']) actually set? If everything goes to the default controller, then this should be because either the PATH_INFO variable is not being past as you expect, or there is an issue with the routing, which should result in the same situation on AUTO.



回答2:

From CodeIgniter user guide:

If you find that no matter what you put in your URL only your default page is loading, it might be that your server does not support the PATH_INFO variable needed to serve search-engine friendly URLs. As a first step, open your application/config/config.php file and look for the URI Protocol information. It will recommend that you try a couple alternate settings. If it still doesn't work after you've tried this you'll need to force CodeIgniter to add a question mark to your URLs.

Link: http://ellislab.com/codeigniter/user-guide/installation/troubleshooting.html



回答3:

I've had the same problem as you (are you using GoDaddy by any chance?), and the question below helped me:

See Codeigniter $config['uri_protocol'] problem. Look at the second answer, in the comments.