Tricky - you might hit problems with some WordPress urls, e.g. wp-login.php, but you could add exclusions.
I'd also use a return 301 rather than a rewrite.
So something more like this (untested):
location ~ ^/(?!wp-login\.php$|wp-admin/|wp-includes/|index\.php$)(.+)\.php$ {
return 301 /$1;
}
But if you can get a list of old urls then using a map might be better/safer e.g. (also untested):
map $request_uri $new_uri {
default "";
/url1.php /new-path-1;
/url2.php /new-path-2;
# etc
}
server {
...
# Redirect old url.php requests to new paths
location ~ ^/url[0-9]+\.php$ {
if ($new_uri) {
return 301 $new_uri;
}
return 404;
}
etc
kevinjmcmahonjr I plan to put it in the site's nginx config that WordOps provides after the index but before any includes.
Bear in mind processing order in Nginx is based on match type first of all, which also applies to includes. Everything is treated as one big file so e.g. Exact match ('=') will always override '~' even if in a later include.