TahirU.
TahirU.

Reputation: 1

Codeigniter + Nginx 404 not found

I'm having trouble configuring Codeigniter 2 with nginx. No problem with the landing page. But permalinks is not found.

404 Not Found

nginx

Htaccess:

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

What should I do?

Many Thanks.

Upvotes: 0

Views: 5631

Answers (2)

Alvin Chettiar
Alvin Chettiar

Reputation: 609

Nginx checks the case of the class loaded and the name of the file.

Ex: class name is Login. File name is login.php Result: 404.

Change the file name to Login.php and nginx would start working as expected.

Imp Note: Class name and file name's case should match.

Upvotes: 2

Tpojka
Tpojka

Reputation: 7111

To clarify, the .htaccess file is for apache servers and therefore does nothing for your nginx server. You have to configure /etc/nginx/nginx.conf file. Before that you should backup your current file cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup.

Then, try this one code:

# nginx configuration
location / {
    if (!-e $request_filename){
        rewrite ^(.*)$ /index.php/$1 break;
    }
}

Disclaimer: I used this online service to get the code.

Upvotes: 0

Related Questions