Deafult views in the Views 2 Module have an SEO issue. They don't send 404 errors when a non-existent URL is requested.

For example, if your view is located at
example.com/articles

and your page is at:
example.com/articles/my-page

but you accidentally link to:
example.com/articles/mypage

Drupal sends a "200 OK" header and the content from:
example.com/articles

instead of sending a 404 header/page.

Is there a way to fix that in the Views settings or should I add an issue to the Views module?

Comments

Target-Tom’s picture

Same Problem here. This is really a big Problem because it creates duplicate pages with no content. Especially when you change your URL-structure.

Target-Tom’s picture

As i needed a quick solution i figured a workaround. Just use a name other than the "directory" for the view.

For Example:

example.com/articles/myexistingpage > 200
example.com/articles/mynonexistingpage > 404
example.com/articles/ > 404
example.com/articles/view > 200

Slovak’s picture

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: to Hide view / Page not found (404). Update the Argument and save the view.

Detailed post at http://peterpetrik.com/blog/2009/11/non-existent-urls-views-2

xsean’s picture

i create a new content/page with url alias http://www.example.com/test

when i key in invalid url http://www.example.com/text/invalid, it suppose go to 404 page but it show same thing like the page from http://www.example.com/test

FranCarstens’s picture

Unfortunately this doesn't seem to work when you have other arguments.

I have a "term name" argument that should give me /folder/term, but also gives me /folder/whatever/whatever/whatever. Adding the "node ID" kills all my "/folder/terms".

Shame... I'm kind of desperate for a solution. (Unfortunately this is still a D5 system so Views 404 won't work.)

-- If no-one asked Drupal questions there would be no Drupal answers --

bisw’s picture

Add global: null field in contextual filter as same as above it will work.

mikeytown2’s picture

Give it a try, it should solve the views 404 issue.
http://drupal.org/project/views404

wesleymusgrove’s picture

Hi,

I ran into the very same issue exactly as described by the OP... 10 years later.

The solution that worked for me was to add a Global: Null contextual filter.

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.

Thanks!

VishnuTRZ’s picture

@wesleymusgrove - the solution is great and its works for me drupal 8.8.8 version.