0

Our PHP installation is intercepting 404 Page Not Found errors and displaying this basic and generic 404 error message on pages with the .php extension:

File not found.

It is preventing the requestor from seeing our nicely formatted ERROR 404 Page.

How do I shut off the PHP setting to have the server use our Apache directives for 404's?

Here is a screenshot of the nicely formatted 404.

Here is a screenshot of the 404 that does not the follow Apache Directives.

H. Ferrence
  • 7,906
  • 31
  • 98
  • 161
  • Are you raising a 404 from within your PHP application, or is it a literal 404 from the file system (and thus Apache's) perspective? Usually there's a rewrite condition forwarding all traffic to a specified handler like `RewriteRule ^(.*)$ index.php [QSA,L]` along with one or two conditions for "file not exists" and "directory not exists". Can you post your htaccess file? – Chris Haas Sep 30 '20 at 17:34
  • @ChrisHaas -- it is not a .htaccess file matter. The entire server (dozens of vhosts) fail to follow the ErrorDocument 404 apache directive when the request is for a .PHP file. The .html files work with the 404 directive. – H. Ferrence Sep 30 '20 at 19:32
  • i think here you find an answere: https://stackoverflow.com/questions/19962787/rewrite-url-after-redirecting-404-error-htaccess – Tobias Oct 07 '20 at 09:22

3 Answers3

1

Check your .htaccess file. Check if custom ErrorDocument is set. For example:

ErrorDocument 404 /file-not-found.php

In addition check if there any redirects matching pages having .php extension. For example:

RewriteCond %{THE_REQUEST} \ /+[^\?]+\.php
RewriteRule ^ - [L,R=404]
  • 1
    This looks correct for me. But there are still a couple of other potential sources of error. For example you have to check if you are allowed to use htaccess files. Most providers like Strato allow it, but there are a few that don't. Also a error in the rest of your htaccess file could cause it to not work properly – Tobias Oct 07 '20 at 09:15
0

I would start looking at the apache conf files (all the conf files in the apache folder i.e. in /etc/apache2 as example, or all the vhost files configuration that should be in something like /etc/apache2/sites-enabled or similar) if nothing is helping there then I would start from having a look at the .htaccess files

as I remember there is nothing in the php configuration that is telling to intercept the 404

d3javu999
  • 323
  • 1
  • 8
  • I looked at everything and ran dozens of tests and tweaks on everything I could think of before posting here. Web docs with .html extensions get the ErrorDocument 404 apache directive to work. Web docs with .php extensions do not. – H. Ferrence Sep 30 '20 at 19:29
  • ahh ok now I understand your request, what you have to do then is to have your html page that is something like – d3javu999 Oct 01 '20 at 08:40
  • Thanks @d3javu999: (1) I really do not understand your comment. (2) But if I do interpret it correctly, the task at hand would be impossible. We have 10's of thousands, if not 100's of thousands of .PHP web documents across our server that powers 50+ vhosts. I/we can't change the way in which we built our web portfolio. (3) Where on earth does the "File Not Found" statement come from on failed .PHP docs only? That's the essence of my question! – H. Ferrence Oct 01 '20 at 10:55
  • File Not Found should came from the Apache configuration or from the http error code, did you try on different browsers? – d3javu999 Oct 01 '20 at 12:27
  • Thanks @d3javu999: different browsers (Chrome, IE, Firefox, Opera), different machines (Windows, Macbook) , different devices (iPhone IOS/Safari). Nothing! – H. Ferrence Oct 01 '20 at 13:23
  • FYI @d3javu999 -- I amended my OQ with example screenshots. – H. Ferrence Oct 01 '20 at 13:40
  • Thanks for asking and sticking with this @d3javu999. No frameworks per se. We run some WordPress (.PHP file extensions fail there while .HTML files do not), running some Bootstrap and some Foundation, a lot of jQuery, etc. but nothing that comes into affect at the OS or Apache web service level. – H. Ferrence Oct 01 '20 at 18:04
  • Apache 2.4 and PHP 7.0 – H. Ferrence Oct 01 '20 at 18:13
  • Actually I'm out of ideas @h – d3javu999 Oct 02 '20 at 08:29
  • @H.Ferrence I'm out of ideas, at this stage I would go and do a more drastic approach using grep. That string should came from somewhere. once you understand which is the page responsible for that you will se who is using that page. There is nothing in the php configuration about 404 pages unless is a framework (i.e. codeignitor, phalcon, etc.). Wordpress should have somewhere in the settings about the 404 page. But mainly I would look in the Apache and vhost configuration first or the .htaccess files. Look in the Apache configuration first the error should reside there. – d3javu999 Oct 02 '20 at 08:36
0

Due to enabling the mod_proxy_fcgi and using PHP-FPM this might happen.The default error page in the proxy is File not Found. Try adding the following in your http.conf or apache.conf

ProxyErrorOverride On
Al-Amin
  • 596
  • 3
  • 16