FastCGI on requests with no extension

I’m running a Caddy webserver with php_fpm. I have a rewrite set where if the requested path doesn’t exist, it tries path.php, so I can have cleaner looking URIs. However, it seems the FastCGI matching is done based on the path and not the real filename, so /contact is not run through FastCGI. How do I make it so that both *.php and [^\ .]* (any requests with no extension) get passed to FastCGI?

Hi @VirtualDXS,

Could you share your Caddyfile so we can see what kind of changes would need to be made?

The fastcgi directive is directed by the base path and the ext subdirective. It operates on the URI, including rewrites, and will try to fallback to an index specified by the index subdirective. If the URI begins with the base path and ends with the value specified by ext, it will be sent to FastCGI.

The available php preset specifies ext .php and index index.php, so if you’re using that, and /contact has no index.php, and you’re not rewriting to a URI that ends in .php, it wouldn’t be forwarded.

Without the php preset, all requests would be forwarded to FastCGI. You could also rewrite /contact /contact.php.

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