I have a script that is being access via a URL like this:


I need nginx to handle this specific route and send it to PHP. Right now my config currently just catches anything ending in .php and sends it to PHP. How can I tweak my config to handle the case above as well?

Here is my nginx block:

# Pass the PHP scripts to FastCGI server listening on
location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;

    # With php5-cgi alone:
    # With php5-fpm:
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;

Your fastcgi_split_pathinfo will not do anything, cause the location does not contain a slash and is anchored at the match end. Use a location like this:

 location ~ \.php/ {
     fastcgi_split_pathinfo ^(.*\.php)(/.*)$;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.