Still confused with try_files

mike mike503 at
Tue Mar 17 07:44:30 MSK 2009

for a site with multiple "if file does not exist, use this master
controller file" like wordpress, drupal, etc, does a config like this
make sense?

because right now, it doesn't.

the /blog one does, but the /second one doesn.t

server {
        listen 80;
        index index.php index.html;
        root /home/proto/web/;
        include /etc/nginx/defaults.conf;
        include /etc/nginx/expires.conf;
        location /blog {
                error_page 404 = /wordpress/index.php?q=$request_uri;
        location /second {
                try_files $uri $uri/ /second/controller.php?slug=$request_uri;
        location ~ \.php$ {

2009/03/16 21:40:29 [error] 29669#0: *638 rewrite or internal
redirection cycle while internal redirect to
"/second/controller.php?slug=/second/contro", client:,
server:, request: "GET /second/contro HTTP/1.1", host:

I really want to use try_files as I believe it is better than using
error_page 404 and if ( !-e $request_filename) type stuff, right? All
I need is to understand the routing better and I'll be on my way. :)

I guess it makes sense about the internal redirection cycle but how
else can I route only requests to the prefix of /second to that
application's controller?


More information about the nginx mailing list