[support] setting.php - changing Drupal's admin path

dir.dev at digitalreef.net dir.dev at digitalreef.net
Wed Feb 1 13:03:35 UTC 2006


> Op woensdag 1 februari 2006 11:07, schreef RobiW:
>> I have a similar problem and the reason is that our ISP provides
>> administrative features like stats, spam control etc with the url using
>> www.mydomain.co.uk/admin which conflicts with Drupal admin feature and I
>> have not been able to find any way to change it in Drupal.
>>
>> Havn't found a way round it yet!

Hey Rob -

If you are willing to make some changes to your Drupal
modules/user.module, you can change the URL for the Drupal admin
functions. Here's the relevant section (from ver 4.6.5):

    //admin pages
    $items[] = array('path' => 'admin/user', 'title' => t('users'),
      'callback' => 'user_admin', 'access' => $admin_access);
    $items[] = array('path' => 'admin/user/list', 'title' => t('list'),
      'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
    $items[] = array('path' => 'admin/user/create', 'title' => t('add user'),
      'callback' => 'user_admin', 'access' => $admin_access,
      'type' => MENU_LOCAL_TASK);
    $items[] = array('path' => 'admin/user/configure', 'title' =>
t('configure'),
      'callback' => 'user_configure', 'access' => $admin_access,
      'type' => MENU_LOCAL_TASK);
    $items[] = array('path' => 'admin/access', 'title' => t('access
control'),
      'callback' => 'user_admin_perm', 'access' => $admin_access);
    $items[] = array('path' => 'admin/access/permissions', 'title' =>
t('permissions'),
      'callback' => 'user_admin_perm', 'access' => $admin_access,
      'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10);
    $items[] = array('path' => 'admin/access/roles', 'title' => t('roles'),
      'callback' => 'user_admin_role', 'access' => $admin_access,
      'type' => MENU_LOCAL_TASK);
    $items[] = array('path' => 'admin/access/roles/edit', 'title' =>
t('edit role'),
      'callback' => 'user_admin_role', 'access' => $admin_access,
      'type' => MENU_CALLBACK);
    $items[] = array('path' => 'admin/access/rules', 'title' => t('account
rules'),
      'callback' => 'user_admin_access', 'access' => $admin_access,
      'type' => MENU_LOCAL_TASK, 'weight' => 10);
    $items[] = array('path' => 'admin/access/rules/list', 'title' =>
t('list'),
      'access' => $admin_access, 'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10);
    $items[] = array('path' => 'admin/access/rules/add', 'title' => t('add
rule'),
      'callback' => 'user_admin_access_add', 'access' => $admin_access,
      'type' => MENU_LOCAL_TASK);
    $items[] = array('path' => 'admin/access/rules/check', 'title' =>
t('check rules'),
      'callback' => 'user_admin_access_check', 'access' => $admin_access,
      'type' => MENU_LOCAL_TASK);
    $items[] = array('path' => 'admin/access/rules/edit', 'title' =>
t('edit rule'),
      'callback' => 'user_admin_access_edit', 'access' => $admin_access,
      'type' => MENU_CALLBACK);
    $items[] = array('path' => 'admin/access/rules/delete', 'title' =>
t('delete rule'),
      'callback' => 'user_admin_access_delete', 'access' => $admin_access,
      'type' => MENU_CALLBACK);

    if (module_exist('search')) {
      $items[] = array('path' => 'admin/user/search', 'title' => t('search'),
        'callback' => 'user_admin', 'access' => $admin_access,
        'type' => MENU_LOCAL_TASK);
    }

- - - - -

If you change all of the instances of "admin/" (in the "'path' =>"
sections) to something like "dru_admin/" in the above code segment of your
user.module, all the access URL's will change. I'm pretty sure all of the
form-post actions will update as well, as will the menu links in the
administer menu... that's the beauty of the structure of Drupal. Oh - one
more thing: the menus are cached in Drupal, so changing the code probably
won't affect the site immediately. I think logging out and back in may
refresh the menu cache, or quitting the browser and coming back in to init
a new session.

I haven't actually tested changing the admin paths, and perhaps Ber can
comment on any concerns this change might raise... but this method may be
one way around your ISP-imposed directory names.

Cheers,
--Katin




More information about the support mailing list