I have views set up, with following paths: www.example.com/news www.example.com/projects

If a user goes to www.example.com/projects/not-a-url or www.example.com/news/not/a/real/url it displays the content of /projects or /news accordingly.

Is this a core function? I would prefer it to either 404 or preferably redirect completely.

I have disabled Paths, Pathauto, Redirect, and Global Redirect but it still shows the content for the views when it should be a 404.

  • 2
    Yes this is a core feature and intentional. We’ve got quite a few duplicates of this, I’ll have a hunt around in a bit and find you the best explanation
    – Clive
    Jul 24 '19 at 16:52
  • Thanks @Clive, I've searched but can't find this QA.
    – Sam
    Jul 24 '19 at 17:38

This can be achieved through views contextual filter.

As per wesleymusgrove's asnwer on drupal.org support "Under "WHEN THE FILTER VALUE IS NOT IN THE URL", tell it to "Display all results for the specified field". This allowed me to still see the list of all articles at the views path: example.com/articles

And under "WHEN THE FILTER VALUE IS IN THE URL OR A DEFAULT IS PROVIDED" check "Specify validation criteria", Validator "Content", Content type "Blog post" or "Article" - whatever content type it is. This allowed me to still see a valid post at example.com/articles/my-page, but invalid links like example.com/articles/mypage respond with 404

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.