Pengetahuan

NGINX + CodeIgniter = 404

I’m using Codeigniter for my website, the root website works just fine which has a landing page, however I have a application section located /var/www/water/ and /var/www/fire/ but if i open my application section  it gives me an 404 error.

For your notes, i used Ubuntu 16.04 as Operating System + PHP-FPM 7

So, Below is the configuration of my nginx

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www;
    index index.php index.html index.htm index.nginx-debian.html;

    server_name ariyolo.id;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

then I insert syntax to define the application directory that uses Code Igniter Framework

	location /water {
	try_files $uri $uri/ /water/index.php;
	}

	location /fire {
	try_files $uri $uri/ /water/index.php;
	}

Don’t forget to restart your Nginx service. Tt’s works for me, how about you?

Topik

Related Articles

Close