I was struggling with WordPress and permalinks. The prior onfiguration I had developed worked fine until I switched to permalinks and then it seems to be picked up the js css etc from the root and not the alias.
Google is wonderful as I found this site – http://www.netz39.de/2014/installation-of-wordpress-in-a-subdirectory-with-nginx/.
I thought it was something to do with the way the try_files was working in relation to fastcgi. It was.
So the wordpress config was update to be as below. Note the location rewrite needs to be at the server level.
location @wordpress_rewrite {
rewrite ^/wordpress/(.*)$ /wordpress/index.php?$1;
}
location /wordpress {
alias /media/13eaa8c9-07ee-4dfc-9d1b-adfae0f0248d/www/wordpress;
add_header Content-Security-Policy "default-src 'self' https: data: 'unsafe-inline' 'unsafe-eval';" always;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
index index.php;
try_files $uri $uri/ @wordpress_rewrite;
location ~* /wordpress/(?:uploads|files)/.*\.php$ {
deny all;
}
location ~ ^/wordpress/(.+\.php)$ {
alias /media/13eaa8c9-07ee-4dfc-9d1b-adfae0f0248d/www/wordpress/$1;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi.conf;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/fpm-19e311b1-25e1-4257-8dbc-d49c5ec59015.sock;
}
location = /wordpress/favicon.ico {
access_log off;
log_not_found off;
}
location = /wordpress/robots.txt {
allow all;
access_log off;
log_not_found off;
}
location ~ /wordpress/\. {
deny all;
}
location ~* /wordpress/(?:config)/.*\.php$ {
deny all;
}
location ~* /wordpress/\.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}