I've been trying to get this to work for a couple of hours now, but nothing really seems to work. I've got a Drupal site up and running, and the default location looks like this :
# Default location
location / {
try_files $uri @rewrite;
}
location @rewrite {
rewrite_log on;
rewrite ^/(.*)$ /index.php?q=$1;
}
This works fine, and the end result of this is that all paths not pointing directly to the root (such as 'example.com/subdir1' and 'example.com/subdir1/subdir2') gets rewritten to index.php?q=[path].
However, it happens that I have a few subdirectories on the site which are 'real' subdirectories that contains index.php files. What I would like is to test whether any given subdirectory indeed has an index.php, and then run that one. This is one of my attempts which I thought would work:
# Default location
location / {
try_files $uri @subdir @rewrite;
}
location @subdir {
rewrite_log on;
rewrite ^/(.*)$ $1/index.php;
}
location @rewrite {
rewrite_log on;
rewrite ^/(.*)$ /index.php?q=$1;
}
However, it does not work. I've also tried:
# Default location
location / {
try_files $uri $uri/index.php @rewrite;
}
location @rewrite {
rewrite_log on;
rewrite ^/(.*)$ /index.php?q=$1;
}
That did not work either. I can't figure out what I am doing wrong?
For the record : my configuration file is Drupal & nginx : a sound "general purpose" configuration?