简体   繁体   中英

CodeIgniter 500 Internal Server Error 7

This is actually my first time to upload a CodeIgniter project to a web server. I am having trouble in going to other pages but the index() of the default controller works.

I have searched same situations in the internet but I cannot find any solution.

Here is the .htaccess file

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /schoolportal
  RewriteCond %{REQUEST_URI} ^system.*
  RewriteRule ^(.*)$ /index.php/$1 [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond $1 !^(index\.php|images|robots\.txt|css)
  RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
  ErrorDocument 404 /index.php
</IfModule>

When I try to remove the RewriteBase or change it to just "/", I get a 404 Not Found error.

Here is the config file:

$config['base_url'] = 'http://sctportal.org/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

And the route file:

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

Do some tweaking in config.php:

$config['uri_protocol'] = "REQUEST_URI";

One more thing if you use Linux Server so make these changes is compulsory.

1) Your class name should start with Capital Letter ie cat should be Cat .

2) Save the controller class with Capital Letter ie cat.php should be Cat.php .

Can you please update you .htaccess to the below

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

And you please check you base_url in config file as

$root  = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
$config['base_url']    = "$root";

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = 'index.php';

Remove the index.php from the

$config['index_page'] = 'index.php';

if you don't want the index.php in your url

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM