Google found up some weird links on my website and has started indexing stuff like /taxonomy/term/24/WHATEVER. I don't want that.

I also don't want to find all these URLs manually, ideally they will turn up in Google Webmaster's list of broken links and I can fix them using that list.

Unfortunately in the taxonomy term view at PAGE SETTINGS it just says Path: /taxonomy/term/%. Is there a good way to respond 404 on /taxonomy/term/24/WHATEVER addresses?

  • This comes up every couple of months but I can't find the other posts at the moment - it's how Drupal's path system works; anything in a folder under a/valid/path is considered to be that path. So a/valid/path/foo, a/valid/path/bar, etc, are all considered valid paths, even if there isn't a route explicitly defined for it, so you won't get a 404. As I understand it, that's not easy or even possible to change without a fair number of changes to core code (but might be wrong).
    – Clive
    Commented May 19, 2016 at 14:21
  • I think I answered one of those questions.
    – apaderno
    Commented May 19, 2016 at 14:25

2 Answers 2


You can try Rabbit Hole module.

From its page:

Rabbit Hole is a module that adds the ability to control what should happen when an entity is being viewed at its own page.

This works by providing multiple options to control what should happen when the entity is being viewed at its own page. You have the ability to

  • Deliver an access denied page.

  • Deliver a page not found page.

  • Issue a page redirect to any path or external url.

  • Or simply display the entity (regular behavior).

Supported entities

The currently supported entities are:

  • Nodes
  • Taxonomy terms
  • Users
  • Files

I've done something similar, but there might be some edge cases where this solution might not be suitable.

You can use hook_taxonomy_term_view() and within that check if the amount of arguments in the URL ($_GET['q']) is more than three.

 * Implements hook_taxonomy_term_view().
function custom_module_taxonomy_term_view($term, $view_mode, $langcode) {
  if (count(arg()) > 3) {
    // This will throw a 404.

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.