You should use the ^~
prefix on the location
statement, change the alias
statement to root /var/www;
, and change the last parameter of the try_files
statement.
For example:
location ^~ /blog/ {
autoindex on;
root /var/www;
index index.php;
try_files $uri $uri/ /blog/index.php?$args;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
}