Sometime we have requirement to disable user registration page or some node pages and redirect it to “404 page not found”, we can do this using below code.


<?php
/**
* Implements hook_menu_alter().
*/
function my_module_menu_alter(&$items) {
//disable or redirects node/10 page to 404 page
$items['node/10']['page callback'] = 'drupal_not_found';
$items['node/10']['access callback'] = FALSE;
//disable user registration
$items['user/register']['page callback'] = 'drupal_not_found';
$items['user/register']['access callback'] = FALSE;
}
?>

Advertisements