homepage Welcome to WebmasterWorld Guest from 54.204.168.212
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
404 not working
on PHP pages
lee_sufc

10+ Year Member



 
Msg#: 3654777 posted 8:12 pm on May 20, 2008 (gmt 0)

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?

 

Receptional Andy



 
Msg#: 3654777 posted 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?

coopster

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



 
Msg#: 3654777 posted 8:17 pm on May 20, 2008 (gmt 0)

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.

lee_sufc

10+ Year Member



 
Msg#: 3654777 posted 8:19 pm on May 20, 2008 (gmt 0)

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!

Receptional Andy



 
Msg#: 3654777 posted 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]

coopster

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



 
Msg#: 3654777 posted 8:28 pm on May 20, 2008 (gmt 0)

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.

lee_sufc

10+ Year Member



 
Msg#: 3654777 posted 8:32 pm on May 20, 2008 (gmt 0)

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!

lee_sufc

10+ Year Member



 
Msg#: 3654777 posted 8:12 pm on May 21, 2008 (gmt 0)

Any ideas?

Receptional Andy



 
Msg#: 3654777 posted 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.

lee_sufc

10+ Year Member



 
Msg#: 3654777 posted 8:30 pm on May 21, 2008 (gmt 0)

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?

Receptional Andy



 
Msg#: 3654777 posted 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?

lee_sufc

10+ Year Member



 
Msg#: 3654777 posted 8:49 pm on May 21, 2008 (gmt 0)

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.

Receptional Andy



 
Msg#: 3654777 posted 8:57 pm on May 21, 2008 (gmt 0)

It does sound like a (server) misconfiguration problem, so hopefully your host will be responsive.

lee_sufc

10+ Year Member



 
Msg#: 3654777 posted 9:04 pm on May 21, 2008 (gmt 0)

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?

Receptional Andy



 
Msg#: 3654777 posted 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).

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved