Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange issue with 404 error pages

I have a website set up that uses a custom 404 error page. This seems to be working on most pages.

In fact, I have two different error pages that I want to show, and now a third that I just found out about.

This page, which does not exist, shows the correct error page that should be shown if a page cannot be found. This shows the error page as configured in my .htaccess file: http://www.canadiancommuter.com/wontfindthis.php

This error page is generated from my PHP code if someone tries to access an old article that no longer exists in the database: http://www.canadiancommuter.com/2334054466-some+old+article.html

However, this link, which will also generate a 404 error, shows a different error page (which usually includes advertising): http://www.canadiancommuter.com/2012062500-TTC+asks+Ministry+of+Labour+to+treat+CNE+like+Rolling+Stones+concert%2FCaribana.html

I know the reason WHY this URL doesn't work. I purposely added characters to it to cause it to return a 404 error. My problem is that I can't figure out WHERE this other 404 error page is coming from.

It's not in my .htaccess file, the error page from my .htaccess file can be seen in the first link above.

It's not in my code. The only error page generated by the code itself can be seen in the second link above.

The only other places it could come from is my domain registrar, and my web host.

The domain is registered through one registrar, but points to my hosting account with another provider. The registrar says that because I'm just pointing the DNS for my domain to we web host the error page wouldn't come from them, but would come from my web host.

My web host says this error page isn't coming from them, but must be in my code.

I've heavily modified all of the code used for this site, so I'm pretty confident that the error page is not coming from there.

Does anyone have any ideas where I should look for this error page?

(Just a note, I'm not certain the registrar or the web host were entirely sure of what they were talking about, so I haven't ruled out either of them as being the source of this page. However, a thorough look through the administrative consoles for both do not reveal anything to this effect.)

like image 718
Sherwin Flight Avatar asked Feb 19 '23 15:02

Sherwin Flight


2 Answers

Your pages are being served through a proxy running cloudflare-nginx which could be catching some 404 errors because slashes in either / or %2F form cause a different 404 page to be served.

Do you have an .htaccess rule that catches all of the possible 404 errors and not just the ones that match your filename scheme? If not, try setting one up. You could also try to run the site in a local server instance and see if the 404 pages behave as expected.

Edited because I mistakenly took characters produced by Transfer-encoding: chunked to be caused by misconfifguration

like image 143
Kaivosukeltaja Avatar answered Feb 22 '23 03:02

Kaivosukeltaja


If (as you have already determined) your code doesn't generate the error page, then the "mysterious" 404 page comes either from the default websersver configuration (which is presumably controlled by your hosting provider) or indirectly from your DNS service (if your webserver redirects your browser to an unregistered domain, for example, then you may be redirected to a page which invites you to buy it).

The most straightforward way IMO to track this down is by using a browser equipped with machinery for tracking redirects (e.g. Firefox with the Firebug extension installed). If the error pages are indeed coming from your domain (and not a misspelling of it), then that implicates the default webserver configuration (and so presumably your hosting provider).

EDIT: Re-reading the above I realize that I should clarify: your DNS service can't simply "redirect" you somewhere. If you find that typing a non-existing domain into your browser redirects you to a page with advertising then you can be fairly sure that it's your network connectivity provider that is inspecting your HTTP request, doing a DNS looking on your behalf behind the scenes, and redirecting you.

like image 32
Peter Avatar answered Feb 22 '23 05:02

Peter