Reputation: 200
I downloaded a PHP script written using CodeIgniter. when I run it from the localhost, on going to the admin folder, it shows localhost again. Also when running from my web host, it shows a 500 Internal Server Error.
I run the site from http://localhost/myproj It works. Then when I try to go to the admin page which is at http://localhost/myproj/administrator, it gives a 500 Internal Server Error.
I read here that this might be due to a wrong code in the .htaccess file. This is my present .htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
Please help me. I know it might be a very small problem, but I'm unable to find the error.
Upvotes: 13
Views: 161640
Reputation: 393
If your are using local server, this problem is faced in Wampserver when the essential modules are not enable.
You can Enable them with:
Left click on Wampsever icon
Go to APACHE -> APACHE MODULES
scroll down and find "rewrite_module" and "headers_module"
Then mark them check
It will restart automatically. Done.
Upvotes: 0
Reputation: 540
Pretty late to the party but, i think the best approach to 500 internal server errors in CodeIgniter would be to enable the error log functionality in the Config.php file in the config folder and set a threshold value i.e. $config['log_threshold'] = 1,2,3,4 depending on the logs you want to view.
Upvotes: 1
Reputation: 2880
Make sure your root index.php
file has the correct permission, its permission must be 0755
or 0644
Upvotes: 4
Reputation: 1
This works fine for me
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule >
Upvotes: 0
Reputation: 239
Try this to your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule >
Upvotes: 3
Reputation: 11
if The wampserver Version 2.5 then change apache configuration as
httpd.conf (apache configuration file): From
#LoadModule rewrite_module modules/mod_rewrite.so**
To ,delete the #
LoadModule rewrite_module modules/mod_rewrite.so**
this working fine to me
Upvotes: 1
Reputation: 87
remove comment in httpd.conf (apache configuration file):
LoadModule rewrite_module modules/mod_rewrite.so
Upvotes: 2
Reputation: 2137
I know I am late, but this will help someone.
Check if rewrite engine is enabled.
If not, enable rewrite engine and restart server.
sudo a2enmod rewrite
sudo service apache2 restart
Upvotes: 1
Reputation: 1199
This probably isn't relevant any more to this thread, but hopefully helpful to somebody. I've had 500 errors for the past hour as I had a controller return an array not supported by the php version ran on my (crappy) server. Seems trivial but had the hallmarks of a codeigniter error.
I had to use:
class emck_model extends CI_Model {
public function getTiles(){
return array(...);
}
}
Instead of
class emck_model extends CI_Model {
public function getTiles(){
return [...];
}
}
Cheers
Upvotes: 0
Reputation: 2060
Just in case somebody else stumbles across this problem, I inherited an older CodeIgniter project and had a lot of trouble getting it to install.
I wasted a ton of time trying to create a local installation of the site and tried everything. In the end, the solution was simple.
The problem is that older CodeIgniter versions (like 1.7 and below), don't work with PHP 5.3. The solution is to switch to PHP 5.2 or something older.
Upvotes: 5
Reputation: 6346
The problem with 500 errors (with CodeIgniter), with different apache settings, it displays 500 error when there's an error with PHP configuration.
Here's how it can trigger 500 error with CodeIgniter:
Please check your apache error logs, there should be some interesting information in there.
Upvotes: 35
Reputation: 158
You're trying to remove index.php from your site URL's, correct?
Try setting your $config['uri_protocol']
to REQUEST_URI
instead of AUTO
.
Upvotes: 4
Reputation: 9299
Whenever I run CodeIgniter in a sub directory I set the RewriteBase
to it. Try setting it as /myproj/
instead of /
.
Upvotes: 1