Join the web development community

I would like to change the user and admin directory of Drupal 7

I would like to change the user and admin directory path name of Drupal 7 to exclude some nasty bots from trying to get in. Is there any way to do this in Drupal 7?

Junaed's picture

Rename the paths

Vote the answer: 
3
Average: 3 (1 vote)

If I understand your problem correctly, you can change the name of admin to stop the bots. And its is very easy on Drupal 7.  On Drupal 7 you will find a dedicated module for this job. On  Drupal 6 you may have to write some codes on the settings file. You can use the module Rename Admin Paths to change the admin path. Using this module you can change the path like-

 /admin/... to /name you like/...

 

Again, I think to change the name of /user/login will be the solution you are after. You can do this by writing a module. You just have to set aside the /user/login path from the menu and set it as access denied. You can use hook_menu_alter to do this. Again using the hoo_menu, you can then define another path redirected to the login page. You can create a .info file. Then you ok to install. You will find more on creating .info file here. Then, this module will provide you another login path /hiddenloginpath.

/**
* Implementation of hook_menu.
* Create our new path to the new login screen.
*/
function moveloginpage_menu() {
$items = array();

$items['supersecretloginplace'] = array(
'title' => 'Super Secret Login Page',
'page callback' => 'moveloginpage_user_page',
'page arguments' => array(true),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);

return $items;
}

/**
* Implementation of hook_menu_alter.
* Tell the menu system to use our custom callback rather than the core callback.
*/
function moveloginpage_menu_alter(&$items) {
$items['user']['page callback'] = 'moveloginpage_user_page';
}

/**
* Access callback for path /user.
*
* Displays user profile if user is logged in, or login form for anonymous
* users if using our special path, access denied if using default path.
*/
function moveloginpage_user_page($show = false) {
global $user;
if ($user->uid) {
menu_set_active_item('user/'. $user->uid);
return menu_execute_active_handler();
}
else if ($show) {
return drupal_get_form('user_login');
}

drupal_access_denied();
}

You will find more about this here. If you find any other solution, then please let me know. Hope this helps.