In the last chapter, you created a 404 Page for your site. ExpressionEngine allows for great flexibility with URLs and the downside of that is that invalid URLs can often return valid content.
As an example, if you type in an entry URL that does not exist (such as http://localhost/faqs/browse/ihatetoast
, you see an actual page with content instead of your 404 template. This can be confusing to visitors if they mistype the URL. Luckily, there are options available to fix this.
ExpressionEngine comes with a redirect tag that you can use to redirect visitors to another template, based on a conditional. Typically, the syntax of this tag would be {redirect="template_group/template"}.
However, when redirecting to a 404 Page, rather than redirecting to "includes/404"
, you can redirect to "404".
This will return the template that you defined in Chapter 4 as your 404 template (if you have not yet defined this template, you can do so in Design | Templates | Global Preferences...