PHP and nonexistant files

one weird thing I noticed with caddy and PHP is that when specifying a non-existant file (aka a 404 link), instead of the normal 404 page it throws an “No input file specified.”

is there a way to fix that, so that caddy essentially doesnt try anything with PHP but just does the 404?

I believe that has to to with the FastCGI method employed.

You could implement a fallback rewrite so Caddy never tries a file that doesn’t exist, e.g;

rewrite {
    to {path} {path}/ index.php

I understand that a request to /nonexistent.php would then have Caddy check for that file, then for the directory /nonexistent.php/, and then load up index.php instead of telling fastcgi to load a nonexistent file. Change index.php to index.html if appropriate.

1 Like

well at least the HTML file, will certainly not throw a 404 to the browser or any given machine so they can handle the page as “error page” for PHP it might be possible, although I didnt try yet.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.