How do I force a 403/410 error code for specific users and content? I have a content type in a Drupal 6 site that allows the creator of a node to mark the node as "withdrawn"; he can still see it, but attempts by others to see it are caught and redirected somewhere else, like their user page.

So far so good, but I'm concerned about what happens when search bots show up looking for the node; they get a 302 response from the server and are then redirected to the "somewhere else" page with an http code 200. What ought to happen (I think) is that the request by Googlebot for the node should result in a 403 or 410 error code, causing (eventually) the page to get dropped from the Google index. So I'd like to have the page generation work just like it is, except with a 401/410/whatever getting sent back as the response to the initial request.

I've tried putting some header() calls into the part of the code that detects the disallowed access, but they're not working, presumably because I'm too far along in the page construction by the time that call happens for the new header information to matter.

Is there any way to get this error code generated while still getting the user to the page I want them to be at?
drupal_goto Can help you

drupal_goto($path = '', $query = NULL, $fragment = NULL, $http_response_code = 302)


Parameters


$path:
A Drupal path or a full URL.

$query:
A URL-encoded query string to append to the link, or an array of query
key/value-pairs without any URL-encoding. Passed to url().

$fragment:
A destination fragment identifier (named anchor).

$http_response_code:
Valid values for an actual &quot;goto&quot; as per RFC 2616 section 10.3 are:


301 Moved Permanently (the recommended value for most redirects)
302 Found (default in Drupal and PHP, sometimes used for spamming search
engines)
303 See Other
304 Not Modified
305 Use Proxy
307 Temporary Redirect (alternative to &quot;503 Site Down for Maintenance&quot;)


Note: Other values are defined by RFC 2616, but are rarely used and poorly
supported.