GabeMeister
GabeMeister

Reputation: 1868

500 Internal Server Error CodeIgniter htaccess mod_rewrite

I coded my web application on windows, and I am pushing it to my server, which runs Ubuntu Linux. Here is my .htaccess file:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /SearchDatGifUbuntu/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
  # If we don't have mod_rewrite installed, all 404's
  # can be sent to index.php, and everything works as normal.
  ErrorDocument 404 /index.php
</IfModule>

My file at /etc/apache2/sites-available/default is as follows:

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

I typed sudo a2enmod rewrite into the command line on my ubuntu server, and it says mod_rewrite is already turned on.

As I debugged through my codeigniter application, the error seemed to show up on line 308 in CodeIgniter.php, which is:

$CI = new $class();

Can someone please let me know what is going on?

Upvotes: 1

Views: 15133

Answers (3)

Indonesia Publisher
Indonesia Publisher

Reputation: 11

Create a .htaccess file in your CI project folder. Enter the code below in the file.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Upvotes: 1

paulc
paulc

Reputation: 485

I had to edit:

/etc/apache2/apache2.conf

and set:

<Directory /var/www/html>
    # ... other directives...
    AllowOverride All
 </Directory>

And then restart apache, in order for the above .htaccess code to be read.

Upvotes: 2

Shahjahan Jewel
Shahjahan Jewel

Reputation: 2362

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]  

Try this .htaccess code, and restart your apache

If this does not work please try this link

How to enable mod_rewrite for Apache 2.2

Upvotes: 4

Related Questions