3

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?

apaderno
  • 28,547
  • 16
  • 75
  • 90
夏期劇場
  • 17,821
  • 44
  • 135
  • 217

4 Answers4

3

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().

AKS
  • 4,618
  • 2
  • 29
  • 48
1

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.

unor
  • 92,415
  • 26
  • 211
  • 360
1

Look at this, really helpfull http://peterpetrik.com/blog/2009/11/non-existent-urls-views-2

fr1trick
  • 34
  • 1
0

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 .

Zoltan Toth
  • 46,981
  • 12
  • 120
  • 134
Bourkadi
  • 738
  • 1
  • 7
  • 17
  • I think this will not work for 4lvin. The error page works for him, _but_ not for _all_ pages. – unor Sep 06 '12 at 14:00