Internal Server Error in codeigniter on live host

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 19:41:31

What I usually do when migrating to live server are as follows
first .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

then database username and password
application / config / database.php

$db['default'] = array(
'dsn'   => '',
'hostname' => 'localhost',
'username' => 'DATABASE_USERNAME',//database username here
'password' => 'DATABASE_PASSWORD',//database password here
'database' => 'DATABASE_NAME',//database name here
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);

Then in config file application / config / config.php

$config['base_url'] = 'http://example.com/';

if still you are getting error saying cannot connect, try verifying the database username, name and password and try changing the database password just to make sure its correct

UPDATE
Check the file permission and make sure it is 644 and folder permission to 755
Also check php, mysql versions and make sure php version is atlease 5.6 or higher and check server requirements of your framework.

Tamara Stepanov

Try this, its working for me.

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

I had the same problem but I figured it out.

  1. Make sure all your database configuration are collect. Here you may try in your index.php (root);

    if( mysqli_connect('hostname', 'username', 'password', 'database')) { echo 'ok'; }

    if OK then go to your .htaccess file.

  2. In your .htaccess file, Leave this line blank

    RewriteBase /

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!