How to Solve ‘No Input File Specified’ Error on IIS for URLs with Slash

iisphp7

I am running a PHP 7.3 application on IIS using the FastCGI handler to execute the files. When requesting URLs which end on *.php in the browser, everything works fine.

However, some paths of the application look like this: http://my-site.com/image.php/my_image_name.png, i.e., there is some more content after the file name of the PHP file, which is not a query string. For these URLs, IIS always responds with HTTP 404 and the message "No input file specified."

How can I fix this behavior?

Best Answer

To parse URLs like this, PHP scripts use path information provided by PHP. Using the FastCGI handler seems to mess up this path information. Luckily, PHP has a configuration option to fix these paths:

Navigate to your php.ini file and set the following option:

cgi.fix_pathinfo=1

This is the setting recommended by Microsoft when hosting PHP applications on IIS: Using FastCGI to Host PHP Applications on IIS 7