url rewriting cakephp in nginx server centos

Sam Norton

contoh nginx.conf yang men-setting url rewriting :

 

server {
        listen       50081;
        server_name  kodoyo.com;
        rewrite_log on;

        # rewrite rules for cakephp
        location / {
          root   /var/www/kodoyo/webroot;
          index  index.php index.html;

          # If the file exists as a static file serve it
          # directly without running all
          # the other rewite tests on it
          if (-f $request_filename) {
            break;
          }
          if (!-f $request_filename) {
            rewrite ^/(.+)$ /index.php?url=$1 last;
            break;
          }
        }

        location ~ \.php$ {
          fastcgi_pass 127.0.0.1:9000;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME /var/wwwkodoyo/webroot$fastcgi_script_name;
          include fastcgi_params;
        }
    }