Search code examples
phpdrupal-7http-status-code-404drupal-views

Drupal 7: how to return a 404 page not found instead of a view


With the views module (drupal 7) I created a page.

Page settings Path: /news

If I go to ../news I get the news page, what I expect.

When adding a trailing slash at the end I can add everything (after the trailing slash) and the news page will still show up. For instance: ../news/123 etc.

How can I return a 404 instead of the news page? I don't mind using PHP to get it done.

(When I go to ../news123 I do get a 404 what I want).

thx!


Solution

  • From the source:

    The solution is to edit the view by adding an Argument of Node: Nid. Set it to Display all values, Validator: Node, and Argument type of Node ID.

    Set Action to take if argument does not validate: Hide view / Page not found (404). Update the Argument and save the view.