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.
Related
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.
On my site https://www.tvsrbija.online/index.php I have 2 blocks od 728x90 ad and one block of 300x250. Unfortunately these ads are not showing unless they are accessed directly.
https://www.tvsrbija.online/horiz-ad.php (728x90 ad)
https://www.tvsrbija.online/kocka-ad.php (300x250 ad).
As you can see, ads shows just fine when there is not other code on the page.
Note: on https://www.tvsrbija.online/index.php ads are included using php
<? require('kocka-ad.php'); ?>
and
<? require('horiz-ad.php'); ?>
I hope someone can help me troubleshoot this problem.
Also this messages I'm getting in console when visiting my homepage
Failed to load resource: the server responded with a status of 403 (Forbidden)
https://mm.chitika.net/minimall?output=jsonp&publisher=lukapaunovic&unit_id…snip_title=Srpski%20TV%20Kanali%20%3A%3A%20U%C5%BEivo%20%7C%20Po%C4%8Detna Failed to load resource: the server responded with a status of 403 (Forbidden)
https://mm.chitika.net/minimall?output=jsonp&publisher=lukapaunovic&unit_id…snip_title=Srpski%20TV%20Kanali%20%3A%3A%20U%C5%BEivo%20%7C%20Po%C4%8Detna Failed to load resource: the server responded with a status of 403 (Forbidden)
UPDATE: When i removed
<title>Srpski TV Kanali :: Uživo | %TITLE%</title>
ads are showing, i do not understand why. Anyone?
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.
I am trying to get postal codes from this site:
http://pl.wikisource.org/wiki/Lista_kod%C3%B3w_pocztowych_w_Polsce
My code is simple:
<?php
$postalCode = $_GET['code'];
$httpAddr = 'http://pl.wikisource.org/wiki/Lista_kod%C3%B3w_pocztowych_w_Polsce/Okr%C4%99g_'.$postalCode[0].'_'.$postalCode[0].$postalCode[1].'-xxx';
file_get_contents($httpAddr);
?>
But when i set $postalCode to 03-000 (also 01-000, 05-000, but for 07-000, 61-000, 62-000 is working) i am reciving error:
Warning: file_get_contents(http://pl.wikisource.org/wiki/Lista_kod%C3%B3w_pocztowych_w_Polsce/Okr%C4%99g_0_03-xxx): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in /var/www/clients/client1/web4/web/ofix/test.php on line 5
Page address is correct, you can copy and past it in your web browser and it works.
Any ideas?
As Lightness Races in Orbit suspected, it does seem that the webserver is blocking PHP's request.
Using cURL instead of file_get_contents() reveals the details:
HTTP/1.0 403 Forbidden
Scripts should use an informative User-Agent string with contact information, or they may be IP-blocked without notice.
A web browser sends a valid User-Agent header in its request, which is why the page loads OK in your browser but not in PHP.
In my tests loading this URL in PHP, sometimes it succeeds with an HTTP status code of 200, other times it fails with 403. Notice that the error message says scripts may be blocked (ie. sometimes they may not be blocked).
Edit
See this question for more info: How to get results from the Wikipedia API with PHP?
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.