我是CI的新手,请帮我解决 .
路由在localhost中工作,但不在codeigniter项目的在线主机中工作
config.php
$root=(isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST'];
$root.= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;
$config['index_page'] = 'index.php';
routes.php
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['test'] = 'test';
Controller - test.php
class test extends CI_Controller {
public function index()
{
echo "Hi! This is at test";
}
}
Problem is
http://localhost/CodeIgniter-3.0.0/index.php/test -----有效
http://codeignitertests.site50.net/index.php/test ------不要工作
1 回答
当你创建一个控制器时,类和文件名必须有首字母大写
与以前的版本没有问题,但现在在CI3版本中,您必须具有所有类和文件名大写的首字母 .
例如,在调用模型时也是如此 .
将模型加载到控制器上
使用base_url,如果需要,您可以留空,并且应该自动获取您的URL