I did a project in CodeIgniter. It's working fine on my localhost, but giving "500 Internal Server Error" on the remote server. This is my .htaccess file content:
RewriteEngine On
RewriteBase /ezgov
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
                Open httpd.conf generally located in Apache installation directory in windows
/apache/conf/httpd.conf
and
/etc/httpd/httpd.conf
in Unix based systems. httpd.conf is an Apache configuration file which stores various information about the server.
Search for the module mod_rewrite.so or (mod_rewrite.c in rare cases). mod_rewrite module is developed to rewrite the requested URLs on the fly. Most of the time you will find in commented state.
#LoadModule rewrite_module modules/mod_rewrite.*
Here # character represents that it is commented or disabled.
LoadModule rewrite_module modules/mod_rewrite.*
Remove # and restart the Apache Http Server using the command apache -k restart in windows or service httpd restart in unix systems. You also use XAMPP/Wamp UI to restart Apache in windows systems.
Next create .htaccess file in root directory where your CodeIgniter project is located and paste following code
# index file can be index.php, home.php, default.php etc.
DirectoryIndex index.php
# Rewrite engine
RewriteEngine On
# condition with escaping special chars
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
Next Find CodeIgniter configuration file, generally located in it's configuration directory.
./application/config/config.php
Open the file and make $config['index_page'] value empty. which looks like this
/*
  |--------------------------------------------------------------------------
  | 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'] = '';
Now the story is ended. Everything should work fine. You can find more information about httpd.config at Apache Module mod_rewrite. Hope this helps you. Thanks!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With