Understanding URL rewrite in sites-available

Okay, I am using CodeIgniter which likes to use URL rewrites. I can turn
it off, but don’t want to. I was able to deny direct access to index.php
and at one point I was able to have the URL rewrite accept
index.php/non-url/but/url-looking-data which it passed to index.php

My problem is that I have no idea what I am doing, I am just copying
examples and thus I got one working, but when I tried the other I lost
the first fix.

Let my start simple (for my sake) I see that one person said that all
rewrites should be done at the server level instead of the location
level… verification of this? Is that true?

What does !-e $request_filename due?

Why is it better than try_files (which I saw one person use) ?

Exactly what I am trying to do is hide index.php in the URL, but still
send all url requests to index.php WITH the full url so that CodeIgniter
can disect the url and get the paramaters for index.php to process.

Any help is appreciated. I will try to get better questions as I learn
about this.

Posted at Nginx Forum:

Just to give background
http://farinspace.com/codeigniter-nginx-rewrite-rules/ seems to be
exactly what I am trying to do, but it does not work. I get the
index.php page when I go to

but when I go to
it does not send the url information to index.php

Posted at Nginx Forum:

Even more confused… I commented out my entire default file except
server {} and IT STILL LOADS the index.php file WITH the PHP fast
CGI??!!! So basically my default file was doing NOTHING.

My current file:
appears to be a constant or variable

server {
listen 90;

server_name SERVER

access_log PATH_TO_LOG

error_log PATH_TO_LOG

root /var/www;

index index.php index.html

rewrite_log on;

if ($request_ur ~* ^(/welcome(/index)?|index(.php)/?$))


rewrite ^(.*)$ / permanent;


if ($request_uri ~* index/?$)


rewrite ^/(.*)/index?$ /$1 permanent;


if (!-d $request_filename)


#some sites use * and some use + what is the difference?

rewrite ^/(.+)/$ /$1 permanent;


if (!-d $request_uri ~* ^/system)


rewrite ^/(.*)$ /index.php?/$1 last;


if (!-e $request_filename)


rewrite ^/$ index.php/;

rewrite ^(/.*)$ /index.php/$1 last;


error_page 404 /index.php;

#location ~ .php$



fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME DOCROOT$fastcgi_script_name;

include fastcgi_params;


location ~ /.ht


deny all;



Posted at Nginx Forum: