SEO: 404 Headers
In any site, the designer or developer should make sure that the appropriate headers are sent with page requests. It is especially important to ensure that “Not Found” documents send out a proper 404 header.
ExpressionEngine gives you many tools to assist with this, so how about we explore those here?
There is a two-fold way to ensure that pages that do not exist are handled appropriately, so that there is clear communication to both real readers, and search engines, that the page is not found.
The first method is setting up a 404 Error Page which you can do from the Global Template Preferences link in your Templates screen. This feature relies on ExpressionEngine’s template group being a match with Segment 1, and in the case of no match, delivers a 404.
In combination with 404 Error Pages is the ability to require an entry on your Single Entry Page. Here is a code snippet:
{exp:weblog:entries weblog="default_site" limit="1" require_entry="yes"}
<h3>{title}</h3>
{body}
{if no_results}
{redirect="404"}
{/if}
{/exp:weblog:entries}
You can see here that we’re using the require entry parameter. In addition to that, we want our single-entry pages to redirect to a 404 page, so that the search engines do not keep indexing them. For that we can use the no_results conditional with the redirect tag, which is this portion of the above code:
{if no_results}
{redirect="404"}
{/if}
So, how can you confirm that you have set everything up and the correct headers are being delivered? There are many tools out there, including a Live Headers extension for Firefox, as well as tools on the web (try googling “check headers”) that will query a page and tell you what headers are being delivered. That way you can confirm that the search engines are seeing what you intend for them to see.


