Thank you, what you suggest should work. However it appears that paths to non-existent .php files do not make it to my try_files directive. I believe I was too quick to assume that I could fix the problem by modifying $args.
I think the answer I need is to figure out why non-existent .php file paths are not passing along to my try_files directive. I'll post my config below, but to illustrate the problem, here are some URLs:
http://50.56.85.187/about/class-visits
This page loads fine as is. It is Drupal page generated from the /about/class-visits URI.
http://50.56.85.187/about/class-visits.php
This page looks different because it loads an actual php file called class-visits.php in the /about directory.
http://50.56.85.187/about/class-visits.php2
I intentionally screwed up the extension to illustrate that this leads to the normal Drupal 404 page. In other words, this is making it to the fallback part of the try_files directive.
http://50.56.85.187/about/class-visits2.php
I intentionally screwed up the filename this time, to illustrate what happens when a non-existent .php file is requested. (just a general browser error page)
All the above URLs work as I expect except for the fourth one. I need to get that forth one working so that I can have non-existent legacy pages to redirect where I want them to.
Finally here is my config: (I'm a newb, and this is cobbled from the net and trial and error, so I'm sure there are plenty of inefficiencies, feel free to critique!)
server {
listen 80;
server_name 50.56.85.187;
root /sites/art-gallery/trunk;
if ($http_host != "50.56.85.187") {
rewrite ^ http://50.56.85.187$request_uri permanent;
}
index index.php index.html;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS!
location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
deny all;
}
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ^~ /sites/default/files/styles/ {
index index.php index.html;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
break;
}
}
location ~* \.(jpg|jpeg|png|gif|css|js|ico)$ {
expires max;
log_not_found off;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}