Awhile back, working in Drupal 6, I found an issue in which a valid path, say:


would be served if the following did not exist:


I thought it was occurring only with pages defined through Panels and Views, and managed to implement a rather complex check (run during hook_init()) for whether a panel should really be handling that path, and if not, call drupal_not_found().


I just today realized that this same thing occurs with paths defined in Drupal core, e.g.


gets served for


(This answer is what tipped me off: https://drupal.stackexchange.com/a/5080/834)

So evidently, this is happening by design (and through no fault of the CTools-related modules that instate pages through hook_menu()).

I haven't fully been able to dig into menu_get_item() to figure out how it's accepting the extra args, but my question is: does anyone know a way to get around this behavior and make these non-existent paths result in 404s?

1 Answer 1


I don't think you can do that in a general way, this is a behavior that's by design and many modules rely on this, so you would break their optional arguments. In fact, relying on this is currently the only way to support optional arguments without defining a menu router item for every possible combination.

If you want to do it for a specific page callback under your control, you could check if there are any arguments passed to your function with func_get_args() and if so, return a 404.

Note that this "feature" might be removed in 8.x, I've seen it mentioned in an issue.

  • Thanks a bunch. I took a look at hook_menu() and it explains exactly what you're talking about, namely: "If there is no other registered path that fits the requested path better, any further path components are passed to the callback function." and thus the page callback could well be using those extra args.
    – teatime
    Commented Jun 13, 2012 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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