Welcome to WebmasterWorld Guest from 54.211.101.8

Forum Moderators: coopster & jatar k

404 not working

on PHP pages

   
8:12 pm on May 20, 2008 (gmt 0)

10+ Year Member



As the title suggests, on my site, any pages with .php extensions do not show a 404 response for pages that do not exist?!?

Does anyone know why this could be happening?

8:15 pm on May 20, 2008 (gmt 0)



Some clarification would be helpful ;)

How have you set up your 404 pages? If it's an error_document, what code have you used, or if you've used a different mechanism, how is it set up?

8:17 pm on May 20, 2008 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



If you are handling the 404 error pages in PHP yourself, you need to send out the correct HTTP response header and then DO NOT redirect the user with a "Location:" link. Most often, this is the case when these issues arise.
8:19 pm on May 20, 2008 (gmt 0)

10+ Year Member



i do not use, or need custom 404 pages so don't use anything... my htaccess file has the following for a basic non-www redirect:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite\.net [NC]
RewriteRule (.*) [mysite.net...] [R=301,L]

90% of my site is html and 404 pages work fine for them, but for the small number of php pages, I just get a 'this page cannot be displayed error...this occurs when the server is busy...etc' message when typing a URL that doesn't exist in the address bar.

Let me know if you need further information.

Cheers for your help!

8:25 pm on May 20, 2008 (gmt 0)



any pages with .php extensions do not show a 404 response for pages that do not exist

Does this mean that if you go to www.example.com/non-existent.php you get a timeout, but www.example.com/non-existent.htm you get a 404?

[edited by: Receptional_Andy at 8:25 pm (utc) on May 20, 2008]

8:28 pm on May 20, 2008 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Have you had a look at the headers being returned for a non-existent .php page? Firefox has a LiveHttpHeaders extension that is invaluable for troubleshooting issues such as these.
8:32 pm on May 20, 2008 (gmt 0)

10+ Year Member



ReceptionalAndy - yes, that's correct.

coopster, I used an online http header checker and the php pages don't even return a message - just comes up completely blank!

8:12 pm on May 21, 2008 (gmt 0)

10+ Year Member



Any ideas?
8:22 pm on May 21, 2008 (gmt 0)



It's a tricky one, and I'm not sure I've come across it before. The timeout suggests some kind of error server side, but that could be wit hthe server itself, with PHP or perhaps even something different.

It might be worth asking you hosting company about it, or seeing if the same symptoms occur for other sites on the same host.

8:30 pm on May 21, 2008 (gmt 0)

10+ Year Member



Hi Andy

Contacted my host earlier and their resposne was that they think it is something to do with the wordpress code but I could try moving the site to a new server...yeah, helpful!

This is very strange....and frustrating!

Until I find the solution, is this a serious problem?

8:40 pm on May 21, 2008 (gmt 0)



is this a serious problem?

I'd say it's a problem that should be fixed, but whether it's serious depends on how many visitors (and spiders) end up following broken links to php files.

something to do with the wordpress code

It's clearly not a general problem with Wordpress code, otherwise other sites would experience the same. Do you have anything in your error logfiles that might throw some light on it?

8:49 pm on May 21, 2008 (gmt 0)

10+ Year Member



I have just had a look at other sites that share the same server as mine and ALL of them have a problem where if you type in a .php page that doesn't exist, a 404 doesn't get returned.

Have sent my hosts an email about it.

8:57 pm on May 21, 2008 (gmt 0)



It does sound like a (server) misconfiguration problem, so hopefully your host will be responsive.
9:04 pm on May 21, 2008 (gmt 0)

10+ Year Member



Andy, thanks for your help!

Can I just double check (just for peace of mind), that any page, such as www.example.com/nopage.php SHOULD return a 404 response every time?

9:09 pm on May 21, 2008 (gmt 0)



A URL causing a timeout is as a result of either a page, server or network problem that should be fixed. If this is as a result of misconfiguration by your host, then they need to fix it.

The file extension (be that .php or anything else) has no bearing whatsoever on users seeing an error page with a correct status, unless something has gone wrong (which again, should be fixed).

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month