1

We have a normal DNN installation (v09.00.02 366) and we set a 404 page using the "Default Pages" under the site settings.

There's this odd behavior where DNN returns the content of the parent page instead of returning a 404 page when you browse to an non-existent page.

/parent/child => returns the content of /parent

The child page doesn't exist so it should return the 404 page with HTTP status code 404.
How can we change the behavior to follow the desired behavior?

Swimburger
  • 6,681
  • 6
  • 36
  • 63

1 Answers1

1

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];
Will Strohl
  • 1,646
  • 2
  • 15
  • 32
  • 1
    Thanks for the extensive explanation. I understand the reasoning behind this behavior, though I wish we could have best of both worlds. A routing setting in the dnn manifest to let DNN know only to resolve to that page + module when there's a match with that route, otherwise return a 404. Thanks though :) – Swimburger Oct 25 '18 at 22:33
  • The problem with the "canonical" solution is that when you do have "child content", let's say a blog post. In that instance there shouldn't be a canonical, but since the page is shared, there is. So we're forced to make SEO violations either way. – Swimburger Oct 26 '18 at 14:08
  • I completely agree, on both comments. You should consider creating an issue in GitHub to address these concerns. :) – Will Strohl Oct 30 '18 at 23:53