Per the article mentioned above, the CMS no-route page (or the defaultNoRoute action) both set their 404 headers from a controller action with the following code
$this->getResponse()->setHeader('HTTP/1.1','404 Not Found');
If you take a look at the method definition for setHeader
#File: lib/Zend/Controller/Response/Abstract.php
public function setHeader($name, $value, $replace = false)
{
$this->canSendHeaders(true);
$name = $this->_normalizeHeader($name);
$value = (string) $value;
if ($replace) {
foreach ($this->_headers as $key => $header) {
if ($name == $header['name']) {
unset($this->_headers[$key]);
}
}
}
$this->_headers[] = array(
'name' => $name,
'value' => $value,
'replace' => $replace
);
return $this;
}
You can see there's a third paramater named $replace
, which you can use to set a header value again, so something like this
Mage::app()->getResponse()->setHeader('HTTP/1.1','...header text...',true);
should be sufficient to change the value of a header. Just call this before the front controller tells the response object to send its output. You could probably do this from a phtml template (as output is rendered before being sent), but the better way would be with an event listener for the two CMS no route actions (if you've set a custom action for the no-route, adjust accordingly)
controller_action_postdispatch_cms_index_noRoute
controller_action_postdispatch_cms_index_defaultNoRoute