CodeIgniter: 404 Page not found after push for ser

2019-09-07 08:42发布

问题:

I did some apps on my local machine, runs ok, but after send that to the server I am getting 404 error page, I tried all methods but none works, can you help me with that?

a2enmod rewrite is on.

I found in google I need use in the server the same version of my php I have in my localmachine or my app will not run, that is true?

my local: application/config/config.php

$config['base_url'] = 'http://localhost:8888/app/';
$config['index_page'] = 'index.php';

my server: application/config/config.php

$config['base_url'] = 'http://example.com/app';
$config['index_page'] = 'index.php';

I tried too: application/config/config.php

$config['base_url'] = '';
$config['index_page'] = '';

I got stuck on that, can you help me with that?

回答1:

Try this code in your .htaccess file, you are not providing access for your CodeIgniter Directory.

RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ /app/index.php/$1 [L]


回答2:

Do This Configurations

In your config.php

  1. $config['base_url'] = '';
  2. $config['index_page'] = '';
  3. $config['uri_protocol'] = 'AUTO';

in config/routes.php file

$route['default_controller'] = '';//default controller name
$route['404_override'] = '';

then in .htaccess(this should be place out side of application folder)

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


回答3:

The error was: in controllers was like that: user.php so i renamed for User.php, i not understand well that, but fixed online my code.

using user.php run in my local but not in live, if somebody know why, please leave a comment too.

thanks all for the help.

cheers.