Text Size
Sunday, May 20, 2012
Get a look down
JavaScript >> Displaying items by tag: admin path
Displaying items by tag: admin path
Thursday, 08 September 2011 09:35

How to change Drupal's admin path

All Drupal's based websites come's with the same administration path /admin, so if someone know that your site is built with Drupal, he can easily access the admin access page. This path can be changed easily with this little configuration. Just place this code snippet in your settings.php file, and change the admin word with the one you wan't :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Change mywebpanel with the word you need
// Admin page can be seen with the new link : http://www.mywebsite.com/mywebpanel
function custom_url_rewrite($op, $result, $path) {
 
  if ($op == 'alias') {
    if (preg_match('|^admin(/{0,1}.*)|', $path, $matches)) {
      return 'config'. $matches[1];
    }
  }
 
  if ($op == 'source') {
    if (preg_match('|^mywebpanel(/{0,1}.*)|', $path, $matches)) {
      return 'admin'. $matches[1];
    }
  }
 
  return $result;
 
}
Published in Code snippets
Usefull tricks