3

How can I lead to 404 Page Not Found when View page has no result?

I tried this code from http://drupal.org/node/1295824#comment-5192868in "empty text" but the View page still exist with only page title eve if it has not result to list.

<?php
drupal_set_header('HTTP/1.1 404 Not Found');
?>

2 Answers 2

5

You should use the drupal_not_found() function. It sets the correct headers, omits blocks from the page output to conserve CPU and bandwidth, and is the correct way to set a 404 through code in Drupal.

Also see drupal_access_denied() which might be useful.

0

You can use drupal_goto() to redirect and set a proper status code.

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.