Logbook.
CodeIgniter URLs & Nginx Apr. 19 at 9:42 am
As I’m testing the latest release of Passenger for Nginx I’ve also been looking into moving my PHP apps to that web server. Getting CodeIgniter to use friendly URIs with Nginx is fairly simple (after an hour or so of trial and error with various solutions via Google).
I use a sites-available/sites-enabled virtual host setup, and in a CI app’s virtual host I use the following:
server {
listen 80;
server_name domain.tld www.domain.tld;
# redirect to remove www
if ($host = 'www.domain.tld' ) {
rewrite ^/(.*)$ http://domain.tld$uri permanent;
}
location / {
root /var/www/codeigniter/domain.tld/;
index index.php index.html;
# file doesn't exist, let CI handle it
if (!-f $request_filename) {
rewrite ^(.*) /index.php?$1 last;
}
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /opt/nginx/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/codeigniter/domain.tld/index.php;
}
}
Similar to the Lighttpd setup, you need to make CI use the REQUEST_URI for uri_protocol in config/config.php:
$config['uri_protocol'] = "REQUEST_URI";
Recent Entries
- Tide data for Canada Apr. 26 at 10:41 am
- Simple Referral Tracking Nov. 9 at 7:52 am
- Ruby HTML Indentation Jun. 27 at 9:47 am
- SSH Keys May. 28 at 5:01 am
- More logbook entries