The most common instances that a not-found page will properly return a 404 error in DNN are listed below:
- It's a root-level page and doesn't exist https://example.com/not-found
- The page exists, but it's currently deleted, disabled, or protected by permissions (and/or you don't have appropriate permissions)
There are other select instances, but this is the gist of it. This is because of the dynamic nature of DNN. When a module is added to a page, DNN doesn't know if this module is dynamically creating its own URL's or not.
Examples of this include blog and news modules. A non-technical content editor needs to be able to create a new blog post or news item and it should have its own unique URL.
Examples:
Looking at the examples above, DNN couldn't safely redirect as a HTTP 404 error since the pages actually do exist, but only as URL's that are then dynamically used to load custom data from the module on the page.
A solution for this would be to create your own URL provider, which you could base on the one found in the core of DNN.
Another solution would be to ensure that you set stand-alone pages (those without dynamic modules) to have a canonical URL specified. You can do this in the page's respective settings.
More information about the URL provider at the time of release is in the blog post below.
https://www.dnnsoftware.com/community-blog/cid/154518/page-not-found-404-error-handling-in-dnn
On a side note, many of the URL provider features don't have a UI to control them. You can see the URL provider settings by running the following queries to see what the settings are.
-- the highest-level settings
SELECT * FROM [dbo].[HostSettings] WHERE [SettingName] LIKE '%aum_%' ORDER BY [SettingName];
-- setttings for each website, overriding the host-level settings
SELECT * FROM [dbo].[PortalSettings] WHERE [SettingName] LIKE '%aum_%' ORDER BY [PortalId], [SettingName];