夏期劇場
夏期劇場

Reputation: 18325

Drupal 7 some non-existing URLs are not Redirecting to 404?

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:

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:

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

What is it please?

Upvotes: 3

Views: 4511

Answers (4)

fr1trick
fr1trick

Reputation: 34

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

Upvotes: 1

unor
unor

Reputation: 96507

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.

Upvotes: 1

Bourkadi
Bourkadi

Reputation: 746

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 .

Upvotes: 0

AKS
AKS

Reputation: 4658

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

Upvotes: 3

Related Questions