How to remove the drupal default "/node" page (aka the default front page view)

Posted by: 
Dominique De Cooman

As we all know drupal has a default front page which shows a view of teaser nodes promoted to front.
Most sites will replace this page with something else.
But we might forget that we can still go to this page. You might want to remove it.
A simple trick to do this is to make it go to the page not found.
How: drupal has the custom_url_rewrite_inbound function we can use. You should put it in the settings file. Since it is called before drupal loads anything this would be a very good time to change the incomming url and make it go to a page not found.

<?php
//put this in settings.php
function custom_url_rewrite_inbound(&$result$path$path_language) {
  if (
$path == 'node') {
    
//this will cause a page not found
    
$result ''
  }
}
?>

Comments

How to remove the drupal default "/node" page (aka the default front page view)

Or you could use hook_menu_alter.

<?php
/**
* Implementation of hook_menu_alter().
*/
function my_module_menu_alter(&$callbacks) {
unset(
$callbacks['node']);
}
?>

How to remove the drupal default "/node" page (aka the default front page view)

If you allready have a custom module enabled that would be a good solution too.

Add new comment