server { listen 80; server_name localhost; #access_log /var/log/zdir.log combined; index index.html index.htm index.php; root /data/wwwroot/default; location = /favicon.ico { alias /data/wwwroot/default/data/favicon.ico; } location ^~ /templates { if ( !-e $request_filename ){ rewrite ^/templates/(.*) /data/templates/$1 last; } } #rewrite rewrite ^/click/(.*) /index.php?c=click&id=$1 break; rewrite ^/api/(.*)?(.*) /index.php?c=api&method=$1&$2 break; rewrite /login /index.php?c=login break; location ~* ^/(class|controller|db|data|functions|templates)/.*.(php|php5|db3)$ { return 403; } location ~* ^/(data)/.*.(html)$ { deny all; } location /db { deny all; } location ~ [^/]\.php(/|$) { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ { expires 30d; access_log off; } location ~ .*\.(js|css)?$ { expires 7d; access_log off; } location ~ /\.ht { deny all; } }