Drupal – Disable the default node page

In Drupal 6, the default <front> page has the path /node which will list out the latest nodes. Although we could point the <front> page to another path, the /node page is still accessible.

Create a custom module and add the following piece of code would help redirecting /node page back to the <front> page.

/**
 * Implementation of hook_menu_alter().
 */
function YOUR_MODULE_NAME_menu_alter(&amp;$items) {
  $items['node']['page callback'] = '_internal_custom_function_name_here_redirect_to_frontpage';
}

/**
 * Redirect back to the frontpage for specific pages.
 */
function _internal_custom_function_name_here_redirect_to_frontpage() {
  if($_GET['q'] == 'node') {
    $_REQUEST['destination'] = &quot;&lt;front&gt;&quot;;
    drupal_goto();
  }
}

 

I haven’t tried it in Drupal 7, please let me know if you have any idea.

Done =)

Reference: disable the default node page

2 thoughts on “Drupal – Disable the default node page”

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.