location / { # try to serve file directly, fallback to rewrite try_files $uri @rewriteapp; } location @rewriteapp { # rewrite all to index.php rewrite ^(.*)$ /index.php/$1 last; } location ~ ^/index\.php(/|$) { try_files @heroku-fcgi @heroku-fcgi; # ensure that /index.php isn't accessible directly, but only through a rewrite internal; }