Rats! We could not find what you were looking for. Try Again
Proper 404 (page not found) behavior is critical to both the user experience and SEO. You want any URL that is invalid to output a 404 page with the corresponding HTTP header like this one does. That way, both human visitors and web crawlers (or "robots", like Googlebot) know that the URL doesn't exist.
When using a CMS, it can be easy to slip up and serve duplicate content from invalid URLs. These systems are designed to display content dynamically rather than being tied to a specific file on the server that maps to a single URL. This is an advantage of well-designed CMSes to create content once and publish it anywhere you need. But it can also be a disadvantage, by leaving your site with duplicate content on bad URLs.
Unlike many CMSes, controlling 404 behavior with ExpressionEngine is easy, making your site human, search-engine and SEO-friendly.
For example, our privacy/index
template is only designed to serve a single page. No subpages under the privacy
URL segment exist, so near the top of that template, we use:
{if segment_2}
{redirect='404'}
{/if}
For example, our features/index
template has a Channel Entries tag that displays a specific ExpressionEngine feature when a second URL segment is present, e.g. features/create-once-publish-everywhere
. The Channel Entries tag can validate that second URL segment for us. If no entry exists with that URL title, then we can redirect to our 404 page if we require entries.
{exp:channel:entries channel='features' limit='1' require_entry='yes'}
{if no_results}
{redirect='404'}
{/if}
{!-- we have a valid entry, so our single entry tag markup goes here --}
{/exp:channel:entries}