How manage all other http error not managed before? - php

I manage with success some http error code via htaccess redirecting to give page. For example:
Error 404 -> error404.html
Error 500 -> error500.html
But in general is possible manage all other error (not managed before) redirecting it in a unique page? For example:
For all error which not are 404 and 500 then redirect to:
Error XXX -> general-error.html
Thanks.

Related

PHP 404 Not Found header is shown as 404 () in Google Chrome

I have a website. It has a error page with the name 404.php. I set the headers in the 404.php using:
header("HTTP/2 404 Not Found");
When I open console in Google Chrome in the error page now it says:
Failed to load resource: the server responded with a status of 404 ()
Before, it displayed the normal:
Failed to load resource: the server responded with a status of 404 (Not Found)
The word "Not Found" is not displaying in the console tab. So because of this users would think that it is a fake 404 response even if it is real.
Please help me with this.
It works, but it doesn't display "Not Found" in the console and in the network http headers.
I am not seeing anything within the console itself relating to a 404 status code.
Console Output
However, the general header record, as well as the response header record are both displaying a status code of 404.
HTTP Headers
I would not worry about people seeing this as a 'false 404', as per the HTTP status code standards 404 signifies that the page is not found.

I can't access Wordpress Dashboard./js/code/a_0.txt was not found on this server NOT FOUND ERROR

I'm getting this error message:
Not Found
The requested URL
Not Found
/js/code/a_0.txt
The bigger problem is, I can't access dashboard. There's no login box, instead all I can see is blank white page with 2 of those "NOT FOUND" error messages on top. So I can't login and access dashboard
was not found on this server.

I'm getting 503 error instead of 404

When I append a random page name in my website's domain, The server returns: error 503 internal server error. Which is not the case. Because the requested page doesn't exist at all. For example:
When I type:
Www.mysite.Com/foobar.php
The server fires a 503 internal server error. Even though the foobar page doesn't Exist!!
Meanwhile, when I type foobar.html it gives 404 page not found error which is correct.
So how can I fix this?
Thanks in advance.
Edit:
My problem is whenever I request a random page name from my website, it gives 503 error. which is wrong
I want to make it so that when I request a none existing page, it gives error 404, not 503.

How to set Apache HTTP 503 error code instead of HTTP 500 on PHP error

any ideas how to replace Apache HTTP 500 (Internal Server Error) error by HTTP 503 (Service Unavailable) on PHP error once PHP error displaying is off? This is much better option to inform spiders to back to the site soon...
P.S.
would be great to be able to append Retry-After to the 50x error codes if possible...
cheers,
/Marcin
I assume you are referring to PHP's new (since 5.2.4) default behaviour of throwing a 500 if an error occurs, and no other output is being made.
AFAIK, that behaviour is hard-coded, you won't be able to change that without changing PHP itself.
The easiest way may be setting up a custom error handler, and having that throw a 503 for you:
header("HTTP/1.1 503 Service Unavailable");
echo "--- error message here -----";
die();
I wonder if you could do something like an Apache
Redirect 503 /error/500 /maintenance.html
on an
ErrorDocument 500 /error/500
directive?

Custom 404 page sends 200 status code

404 error page's 200 OK header error:
Server Response:
http://www.example.com/err404.html HTTP
Status Code: HTTP/1.1 200 OK
And it should give 404, my client says.
I guess that you use ErrorDocument with an absolute URL like:
ErrorDocument 404 http://example.com/err404.html
In that case the server responds with a 302 redirect with http://example.com/err404.html as the location. If that URL is then requested, your server is sending the 200 status code as you experienced.
Try just an absolute URL path instead:
ErrorDocument 404 /err404.html
You will get status 200 if the error page was the actual request (i.e. the error page is requested directly by browser address bar, a bookmark, a redirect in PHP, etc). You will get status 404 if the error page was returned by the webserver itself when there's actually means of invalid request, or when it is dynamically included by PHP along with header("HTTP/1.1 404 Not Found");. In Apache HTTP server the locations for custom error pages are configureable somewhere in httpd.conf.

Categories