CI and Nginx
Oh, it's time to note the fucking Codeigniter rewrite with Nginx, which will cause a 404
status to make you (╯°□°)╯︵ ┻━┻.
If you use Codeigniter, aka CI, you may know its fucking url rewrite with index.php.
And the rewrite rules are for apache and not nginx. Hence, we should use nginx rewrite rules
to get our site up and running.
Below is a section of my nginx.conf.
server {
listen 80 default;
server_name www.example.com example.com;
root /home/wwwroot/ci/;
index index.php;
location / {
if ($request_filename !~ (index.php)) {
rewrite ^/(.*)$ /index.php?$1 last;
}
}
location ~ .*.(php|php5)?$ {
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ .*.(gif|jpg|jpeg|png|bmp|swf|ttf|svg|woff|eot)$ {
expires 30d;
}
location ~ .*.(js|css)?$ {
expires 12h;
}
access_log /home/logs/ci_access.log access;
error_log /home/logs/ci_error.log;
}
End
If you have something to correct, welcome to point it out:D