CodeIgniter showing only default controller

后端 未结 15 2915
-上瘾入骨i
-上瘾入骨i 2021-02-14 21:59

I am using Codeigniter in Local WAMP. Here code is working fine. But i upload in Cpanel ( inside of example.com, folder name call \'mysite\'). Ther

15条回答
  •  感情败类
    2021-02-14 22:13

    There are few things that you have to take into consideration. when you setup your project with codigniter framework. following is the file that you have to make changes.

    1).htaccess:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /mysite/index.php/$1 [L]  
    

    2)application/config/config.php

    $config['base_url'] = 'http://example.com/mysite/';
    $config['server_root'] = $_SERVER['DOCUMENT_ROOT'];
    $config['index_page'] = '';
    $config['uri_protocol'] = 'AUTO';  
    

    3)application/config/database.php

    $db['default']['hostname'] = 'localhost'; // set your hostname
    $db['default']['username'] = 'root'; // set database username
    $db['default']['password'] = 'root'; //set database password
    $db['default']['database'] = 'XYZ'; //set your database name
    $db['default']['dbdriver'] = 'mysql';
    

    4)application/config/routes.php

    $route['default_controller'] = "user";  //your default controller
    $route['404_override'] = '';  
    

    Note: your .htaccess file must be in root directory. here it should be in mysite folder

提交回复
热议问题