Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter Nginx Rewrite Rule
#1

[eluser]Popcorn[/eluser]
Thought this might of some use to some of you.
Code:
server {
    
    listen   80;
    
    root /var/www/nginx-default/;
    access_log  /var/log/nginx/localhost.access.log;
    index index.php index.html index.htm;

    error_page 500 502 503 504  /50x.html;

    location /codeigniter/ {
        
        if (-f $request_filename) {
            expires max;
            break;
        }
    
        if (!-e $request_filename) {
            rewrite ^/codeigniter/(.*)$ /codeigniter/index.php/$1 last;
        }
    }
    
    location = /50x.html {
        root /var/www/nginx-default;
    }

    location /codeigniter/index.php {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /var/www/nginx-default/codeigniter/index.php;
        include fastcgi_params;
    }
}

The rules inside the location directive basically says : if the file exists then set the maximum expiration date and output it. This is usually css, images, js, etc ...

Then the second rules states that if the file doesn't exist then we assume it's a codeigniter url and redirect the request to the index.php file with the request string.


Messages In This Thread
CodeIgniter Nginx Rewrite Rule - by El Forum - 12-08-2008, 10:43 AM
CodeIgniter Nginx Rewrite Rule - by El Forum - 07-20-2010, 11:57 AM
CodeIgniter Nginx Rewrite Rule - by El Forum - 09-29-2010, 06:37 AM
CodeIgniter Nginx Rewrite Rule - by El Forum - 05-16-2011, 10:06 AM
CodeIgniter Nginx Rewrite Rule - by El Forum - 08-17-2012, 06:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB