When we request for a web page that does not exist in the site, for example, http://sitecorecookbook/test-page/
, Sitecore will redirect you to its default document not found page—notfound.aspx
with a 302 HTTP status code. Here, we expect that the requested page itself should show page not found content with a 404 status without any redirection.
In this recipe, we will achieve this expected behavior by customizing the <httpRequestBegin>
and <httpRequestProcessed>
pipelines.
Create a content item, 404-Page
, in side the Home
item with Title
and Body
fields. Make sure that you have added Title and Body rendering on it. When the requested page does not exist in our site, we will show this page to the user with the 404 status.