Question

In Drupal 7, some of (non-existing) URLs are not redirecting to 404 or any error page it should. Instead, it still remains showing its Top Parent Folder. For example like:

  • www.mywebsite.com/items/aaaaaaaaaaaaa
  • www.mywebsite.com/items/bbbbbbbbbbbbbbbbbb

Every WRONG URLs under /items/ i put like above, are showing the Page of its parent:
www.mywebsite.com/items instead of get redirected to 404
I don't want its parent to be shown if there is no page really.

But the strange thing is, it is NOT happening on every patterns. I mean, another different parents like:

  • www.mywebsite.com/users/aaaaaaaaaaaaa
  • www.mywebsite.com/users/bbbbbbbbbbbbbbbbb

For the wrong url typed-in under this /users/ parent path, it is CORRECTLY redirecting to the 404 page.

What is it please?

Was it helpful?

Solution

OTHER TIPS

If I understand your question correctly, it's not a problem at all.

That's because how your/contributed/core modules hooks Drupal menu system.

If a menu item (menu router item to be specific. Think about a path like "admin/config/development/performance") has no "%" sign in it, menu callback function will be executed. For an example, if a module registers "items" path example.com/items path would not be a 404, and the appropriate menu callback function of the menu item will be fired. That callback function can make use of further URL parts (example.com/items/123) if given.

'node' is a good example. (technically they are different menu router items though) . Opening example.com/node will not fire a 404.

If a module registers 'items/%' , then, example.com/items will fire a 404. In other words, the second URL part is required in order to execute the menu callback function.

If the problem you are facing is related to a custom module, make sure you register the correct version of your router items. If the second URL part is required, register items/%. You can execute a 404 by calling drupal_not_found().

Are you using Views for that path (/items)?

Here is an issue for Views: Prevent duplicate content (because Views returns 200 instead of 400 404)

You could create a Contextual filter to prevent this.

merlinofchaos wrote:

If you don't want this behavior, add the Global: NULL argument to Views and use the setting to validate that the argument is empty.

For Drupal 6, the module Views 404 might help.

You can configure your drupal installation to redirect to a specefic 404 page that you create..

Go to www.yoursite.com/admin/config/system/site-information and enter your 404 page .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top