I've just re-installed Drupal on my site and I tried to change the name of the 'node' to something else but it doesn't work.
Is it possible to change the name of the node to anything such as 'index' or what so ever so my address will become mysite.com/index/add instead of mysite.com/node/add?

Comments

vm’s picture

investigate the path.module (part of core) & the pathauto.module available in the downloads area. After these are running, take a look at the help text in administer -> help for more instruction.

QuickGold’s picture

so I can only generate alias? is it possible to change the name itself without using alias?

thanks,
QG

vm’s picture

generating a url alias is how its done. pathauto helps automate this and provides batch conversion.

misty3’s picture

This is somewhere in the drupal handbooks and it works also for me ( tested in 4.7x )

Add the following code to your settings.php without the php closing or opening tags [ sites/default/settings.php ]
replace whatever_name_you_want_for_node with the name you want instead of node.

function custom_url_rewrite($type, $path, $original) {
  // This path was already aliased, skip rewriting it
  if ($path != $original) {
    return $path;
  }
  if (arg(0) =="node" || arg(0) =="" ) {
        // the system path to change or cloak
        $patterns[0] = '!^node/(\d+)$!';
        $patterns[1] = '!^node/add(/)?(\w+)?$!';
        $patterns[2] = '!^node/(\d+)/edit$!';
        // the new cloaked name
        $replacements[0] = 'whatever_name_you_want_for_node/\1';
        $replacements[1] = 'whatever_name_you_want_for_node/add\1\2';
        $replacements[2] = 'whatever_name_you_want_for_node/\1/edit';
    return preg_replace($patterns, $replacements, $path);
  }
  if ($type == 'source') { // URL coming from a client
        // match the patterns created by the path change
        $patterns[0] = '!^whatever_name_you_want_for_node/(\d+)$!';
        $patterns[1] = '!^whatever_name_you_want_for_node/(\d+)/edit$!';
        $patterns[2] = '!^whatever_name_you_want_for_node/add(/)?(\w+)?$!';
        // send on to the correct system path
        $replacements[0] = 'node/\1';
        $replacements[1] = 'node/\1/edit';
        $replacements[2] = 'node/add/\2';
    return preg_replace($patterns, $replacements, $path);
  }
  elseif ($type == 'alias') { // URL going out to a client
    return preg_replace('!^node/(\d+)$!', 'whatever_name_you_want_for_node/\1', $path);
  }
}

Best regards

vm’s picture

neat trick, like a manual path.module rather than one controlled in the admin area.

QuickGold’s picture

Thank you so much :) This is what I'm looking for and it work on 5.1

wait a minute.. the main page work but not in the Administration Page. looks like there is something needed to be fix. But I don't know what :P

bambam-1’s picture

i've been trying everything to change the name "node" to something else, why isn't the default something like "page" or "content" or anything else!!

i love drupal, everything is working perfectly but this node thing is annoying me, it's just not friendly.

if you gonna make something this important (as to the address of pages) make it flexible to customizable changes.

vm’s picture

drupal is node based, hence "node" and you have two options to change it just in this post, as well as a probable way to change it in .htaccess if you really wanted to investigate that method.

One mans trash is another mans treasure.

Pushkar Gaikwad’s picture

will this code work on 5.7 ?

edit - Yep, works fine for 5.7 too

alexx90’s picture

some one know the way to do this on drupal 6 please

vm’s picture