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.

3
  • 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? Commented Sep 30, 2020 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. Commented Sep 30, 2020 at 19:32
  • i think here you find an answere: stackoverflow.com/questions/19962787/… Commented Oct 7, 2020 at 9:22

3 Answers 3

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]
Sign up to request clarification or add additional context in comments.

1 Comment

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
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

10 Comments

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.
ahh ok now I understand your request, what you have to do then is to have your html page that is something like <?php echo file_get_contents('my beautiful php page path'); ?>
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!
File Not Found should came from the Apache configuration or from the http error code, did you try on different browsers?
Thanks @d3javu999: different browsers (Chrome, IE, Firefox, Opera), different machines (Windows, Macbook) , different devices (iPhone IOS/Safari). Nothing!
|
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.