Mover o location /
no bloco location ~ \.php$
e adicionar essas inclusões abaixo deles finalmente funcionou para mim:
location ~ ^/course/(.+)$ {
try_files $uri $uri/ @extensionless-php;
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
Aqui está o bloco de servidores completo para referência:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/example.com/html;
index index.php index.html index.htm;
client_max_body_size 10M;
server_name example.com;
location ~* "^/something" {
rewrite ^ http://example.com/curso-gratis-habitos/$ $1?ref=conlasalud permanent;
}
location ~* "^/some-other-thing" {
rewrite ^ https://someotherurl.com/? permanent;
}
location ~* "^/something-else" {
rewrite ^ https://someotherurl.com/? permanent;
}
location ~* "^/another-one" {
return 301 https://someotherurl.com/;
}
location ~* "^/special-url" {
return 301 https://someotherurl.com/;
}
set $cache_uri $request_uri;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $cache_uri 'null cache';
}
if ($query_string != "") {
set $cache_uri 'null cache';
}
# Don't cache uris containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $cache_uri 'null cache';
}
# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
set $cache_uri 'null cache';
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# Use cached or actual file if they exists, otherwise pass request to WordPress
location / {
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php;
}
location ~ ^/course/(.+)$ {
try_files $uri $uri/ @extensionless-php;
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
# Enable the hide backend feature - Security > Settings > Hide Login Area > Hide Backend
rewrite ^(/)?somesecreturl/?$ /wp-login.php?$query_string break;
# Protect System Files - Security > Settings > System Tweaks > System Files
location ~ /\.ht { deny all; }
location ~ wp-config.php { deny all; }
location ~ readme.html { deny all; }
location ~ readme.txt { deny all; }
location ~ /install.php { deny all; }
location ^wp-includes/(.*).php { deny all; }
location ^/wp-admin/includes(.*)$ { deny all; }
# Disable PHP in Uploads - Security > Settings > System Tweaks > Uploads
location ^wp\-content/uploads/(.*).php(.?) { deny all; }
}