Codeigniter. Web app works fine in local but in li

2019-07-29 17:08发布

问题:

I currently working in a web app using Codeigniter framework. It works well locally with Wampserver32 but when passing it to a live apache server it only loads the home page and when I try to route to another page it goes: Error - 404

I've already tried changing:

1- $config['index_page'] = 'index.php'; to$config['index_page'] = 'index.php'?;

2- $config['uri_protocol'] = 'REQUEST_URI'; to $config['uri_protocol'] = 'PATH_INFO';

I've actually blocked for 1 day.


confing.php file

...
$config['base_url'] = 'http://s661658794.onlinehome.fr/admin';
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'PATH_INFO';
...

routes.php file

$route['default_controller'] = 'welcome';
$route['Admin'] = 'admin/Login';
$route['Login'] = 'admin/Login/dashboard';
$route['Home'] = 'admin/Home';
$route['Userinfo'] = 'admin/Usercontroller';
$route['History'] = 'admin/Historycontroller';
$route['Changepassword'] = 'admin/Changepassword';
$route['Notification'] = 'admin/Notification';
$route['Logout'] = 'admin/Login/logout';
$route['Forgotpassword'] = 'admin/Login/Forgotpassword';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

.htaccess file

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

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 year"
</IfModule>
## EXPIRES CACHING ##


<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
<ifModule mod_headers.c>
    Header set Connection keep-alive
</ifModule>


RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]

folders

-/
---admin
------application
------assets
------system
------user_guide

回答1:

Looks like you need to adjust your application/config/database.php to match your apache servers database settings.



回答2:

If your index.php file located inside of admin in public_html folder then you need to replace it with following code.

Your code

Rewrite

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

Might be work for you

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