location / { if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1; #rewrite ^/subdir/(.*)$ /subdir/index.php/$1; } }