.php triggers "File not found." (Nginx+Apache+PHP-FM)

Hi, I wanted to ask about this little problem, not sure if its due to the server config because my .htaccess works fine on cPanel sharedhost and on VestaCP vps.

My .htaccess contains

ErrorDocument 404 /index.php

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [NC,QSA,L]

On cPanel and VestaCP, above code just redirects to the root of domain if i entered the domain, domain /index , domain /index.php , domain /non-existent , domain /non-existent.php , domain/ non-existent.etc

with HestiaCP, if i entered domain /index , domain /index.php , domain /non-existent , domain/ non-existent.etc it will redirect to the root of domain, BUT when i enter domain/non-existent .php it shows white page “File not found.”

“File not found” is being triggered by the .php extension if the file does not exist on the server. I wanted it to redirect to the intended 404 document, which is index.php.

How to fix this one? Thanks

VestaCP uses by default modphp instead of php-fpm so error document will be handled by Apache2 instead of php-fpm

To enable this behaviour add

ProxyErrorOverride On

To your Apache2 configuration in the following block

or your apache2 configuration

1 Like

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