How to remove trailing slashes for codeigniter?

Phillip Oldham phill at activityhq.com
Fri Jul 31 18:46:33 MSD 2009


I'm having trouble dropping the trailing slashes to fix issues with 
codeigniter. My setup is as follows:

location / {
    try_files $uri @codeigniter;
}
location @codeigniter {
    rewrite ^ /index.php$uri last;
}


I've tried the following modification:

location @codeigniter {
    rewrite ^/(.*)/$ /$1 permanent;
    rewrite ^ /index.php$uri last;
}

but this only works when the url is:
mysite.org/mypath/     -->    mysite.org/mypath

However, if you access the same path the "long" way 
(mysite.org/index.php/mypath/) the rewrite doesn't get picked up.

Can someone spare a few minutes to explain to me why this is?





More information about the nginx mailing list