When using alias
directive, the SCRIPT_FILENAME
parameter passed onto FastCGI interpreter should be
instead of the default $request_filename
$fastcgi_script_name
. This ensures that the PHP interpreter receives the correct file path and does not return 404 Not Found.
Example Code:
location /myalias { alias /path/to/alias; location ~ \.php$ { fastcgi_pass fastcgi_backend; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $request_filename; } }