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

Advertisements

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s