Codeigniter throws 404 after uploading to server

2019-08-14 03:24发布

问题:

My project runs well on localhost but throws a 404 when I upload the files to a server. Wnen I try to access another page on the system, eg www.myadress.com/newController it throws a 500 internal server error. What could be the problem? This is what my routes look like

$route['default_controller'] = 'home';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

回答1:

use this.

in config.php

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['url_suffix'] = '';

in .htaccess (This should place out side application folder)

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

in autoload.php

$autoload['helper'] = array('url');