ZF-7701: Nginx rewrite rules for reference guide


In the reference guide, chapter 12.5. "The Standard Router", there are rewrite configurations for Apache HTTP Server, Lighttpd and IIS. I think there should also be an example for rewrite rules for the Nginx web server. I have already written such a configuration and it works well on my server.

if (!-e $request_filename) {
  rewrite ^.*$ /index.php last;

I translated it from the extended Apache mod_rewrite example, I'm quite sure it works the same.


Per the nginx wiki, you should avoid using if()'s in nginx configurations if at all possible. The proper way to do this is:

try_files $uri $uri/ /index.php?$args;