View's path prevents 404 page from showing D7, Views 3. I'm kinda puzzled with how Views path work. I have these paths at my site:

mysite.com/people - a view displaying a list of all people

mysite.com/people/alice - an article about Alice

mysite.com/people/bob - there is no such article at mysite.com

When I go to /people/alice I get my article. And when I go to /people/bob I naturally expect to get a 404 page. But /people view is shown instead, probably seeing the "people" part of the path and thinking I've called /people view with some parameter. As I do not expect /people view to have any parameters and always want it to display a list of all people, how do I tell it not to get into Drupal's process of resolving its paths?
This is not a problem with the Views module; it's how Drupal behaves.

If you look at menu_get_item(), you will notice the following code.

$original_map = arg(NULL, $path);

$parts = array_slice($original_map, 0, MENU_MAX_PARTS);
$ancestors = menu_get_ancestors($parts);
$router_item = db_query_range('SELECT * FROM {menu_router} WHERE path IN (:ancestors) ORDER BY fit DESC', 0, 1, array(':ancestors' =&gt; $ancestors))-&gt;fetchAssoc();


I tried the following code, in a test site.

$original_map = arg(NULL, 'people/bob');

$parts = array_slice($original_map, 0, MENU_MAX_PARTS);
$ancestors = menu_get_ancestors($parts);


What I got is an array containing the following items:


people/bob
people/%
people


In your case, as there isn't a menu callback for people/bob, and people/%, the query executed from menu_get_item() will find the menu callback for people, the view you have defined.

To avoid people/bob returns the view page, I would create a custom module with the following code.

function mymodule_menu() {
  $items['people/%'] = array(
    'page callback' =&gt; 'mymodule_people_view',
    'page arguments' =&gt; array(1), 
    'access arguments' =&gt; array('access content'), 
    'type' =&gt; MENU_CALLBACK,
  );
}

function mymodule_people_view($username) {
  $alias = "people/$username";
  $path = drupal_get_normal_path($alias);

  if ($alias == $path) {
    // $alias is not a defined alias; in this case, drupal_get_normal_path()
    // returns the string it gets as argument.
    drupal_not_found();
  }
  else {
    drupal_goto($path);
  }
}


There is a module to resolve this issue (Views 404), which has now a version for Drupal 7.


  Are your views returning a 200 when it should return a 404? Views404 is the answer! This is very helpful for any caching layer and it will help SEO.
  [...]
  Standard Drupal behavior is to pass all arguments through, whether or not they requested. Sometimes this behavior is desired. The views 404 module assumes that by default you do not want arguments passed through. 404s for views can also be accomplished by setting the Global: Null under Arguments.