473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

returning a true 404

Hi Folk

My .htaccess file reads:

ErrorDocument 400 /404.php
ErrorDocument 401 /404.php
ErrorDocument 403 /404.php
ErrorDocument 404 /404.php

This means if someone types in the wrong address (e.g.
www.mysite.com/wrongpage.php ) then they are automatically redirected to
404.php

Now, I would like this to continue, but also return a true 404 (as required
by Google), can you tell me how to do this?

Can you confirm that just placing the following at the top of my script
suffices:

header("HTTP/1.0 404 Not Found");

even if I use ob_start and ob_flush?

Thank you

- Nicolaas
Jan 16 '06 #1
3 1306
windandwaves wrote:
Hi Folk

My .htaccess file reads:

ErrorDocument 400 /404.php
ErrorDocument 401 /404.php
ErrorDocument 403 /404.php
ErrorDocument 404 /404.php
What happened to 400.php, 401.php and 403.php?
This means if someone types in the wrong address (e.g.
www.mysite.com/wrongpage.php ) then they are automatically redirected to
404.php

Now, I would like this to continue, but also return a true 404 (as required
by Google), can you tell me how to do this?

Can you confirm that just placing the following at the top of my script
suffices:

header("HTTP/1.0 404 Not Found");
Yes
even if I use ob_start and ob_flush?


As long the header() statement is the first thing in your script.

Or you could just use ordinary HTML documents for your error pages. The
server will take care of the 404 headers for you.
--
philronan [@] blueyonder [dot] co [dot] uk

Jan 17 '06 #2
Al
I think the guy was wanting to override 400, 401 and 403 with new 404
replies. I'm not sure why but I think that was the intention.

And there's an easy way to test it. Just code it like that and use
either a telnet style program to submit and examine the response
headers yourself or use the "web developer toolkit"
(http://chrispederick.com/work/webdeveloper/) and the firefox browser,
and click Information > View response headers after visiting each
40x-style page.

And it's reasonably easy to reproduce 401 and 403 with permissions and
the like. And the 400 can be reproduced with the telnet style method I
mentioned.

Jan 17 '06 #3
Al wrote:
I think the guy was wanting to override 400, 401 and 403 with new 404
replies. I'm not sure why but I think that was the intention.

And there's an easy way to test it. Just code it like that and use
either a telnet style program to submit and examine the response
headers yourself or use the "web developer toolkit"
(http://chrispederick.com/work/webdeveloper/) and the firefox browser,
and click Information > View response headers after visiting each
40x-style page.

And it's reasonably easy to reproduce 401 and 403 with permissions and
the like. And the 400 can be reproduced with the telnet style method I
mentioned.


Thanks Guys - Awesome. I think I got it sorted. I have that developer
thing on Firefox and it is working superbly now.
Jan 17 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
by: Steven Bethard | last post by:
I have lists containing values that are all either True, False or None, e.g.: etc. For a given list: * If all values are None, the function should return None.
9
by: mjm | last post by:
Folks, Stroustrup indicates that returning by value can be faster than returning by reference but gives no details as to the size of the returned object up to which this holds. My question is...
0
by: John Constant | last post by:
Using the MS C++ Example http://support.microsoft.com/default.aspx?scid=kb;en-us;261003 I've successfully managed to trap and log Script Errors that are generated by the WebBrowser (IE 6) which is...
6
by: Derrick | last post by:
Hello all; Since I do have working code, this is more for my curiosity only. I'm creating a "Plugin" architecture, following some of the many examples on the 'net. Basically what I have is...
4
by: Earl T | last post by:
When I try to get the netscape version for version 7, I get the HttpBrowserCapabilities class returning the version as 5 and not 7. (see code and output below) CODE HttpBrowserCapabilities...
1
by: Joe Van Meer | last post by:
Hi all, I have an app that currently runs through 3 seperate stored procedures each returning a count of records. What I would like to do is combine these calls into one call, however I am...
11
by: klove1209 | last post by:
Good afternoon, Can someone please guide me towards how to return records from a table. I currently have a table with about 21 fields, and 21 records. I have one field that is just text and the...
13
by: agent-s | last post by:
I have a function, generally described as so: def function(args): if condition: if condition2: function(args+1) elif condition3: print "text" return True else:
10
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm using this coding to get 2 resultsets thru datareader and then load them into 2 datatables and bind the datatables to datagridviews. But sdrGrid.NextResult() is returning false for some...
3
rsmccli
by: rsmccli | last post by:
Access 2002 Hi. I have a command button that will "approve" all records currently being looked at by an "approver". For some reason, even though there are multiple records that exist in the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.