codeigniter not work at live page not found error

2019-02-17 16:21发布

问题:

my codeigniter work perfectly on local host but not work at live.my codeigniter is latest version.i also try older.it always show me page not found on redirect.

routes.php setting is

$route['default_controller'] = "home";
$route['404_override'] = '';

i also upload htaccess on server.i tried in linux and window both.

htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

回答1:

you can do:

$config['base_url'] = 'http://'.$_SERVER['HTTP_HOST']; //you can also leave blank this CI tend to find this by himself
$config['index_page'] = '';

$config['uri_protocol'] = 'AUTO'; //if not working try one of these:
     'PATH_INFO'        Uses the PATH_INFO
    | 'QUERY_STRING'    Uses the QUERY_STRING
    | 'REQUEST_URI'     Uses the REQUEST_URI
    | 'ORIG_PATH_INFO'  Uses the ORIG_PATH_INFO

and try this .htaccess i use for many sites

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

if not working yet, use a phpinfo(); and check if mod_rewrite is enabled