[Drupal] How to change the admin url from /admin to /config in Drupal 6.x

Change the URL for the admin panel: /admin/ will be no more accessible. The goal is to avoid hacks.

Let say we want to change the entry of backend from /admin to /config, that is the web user is deny when visit http://www.example.com/admin, but allow to visit http://www.example.com/config

1. Modify the settings.php add the code to the end of this file :

代码
/**
*
* Change the admin link from /admin to /config
*
*/
function custom_url_rewrite_outbound(&$path, &$options, $original_path) {
global
$user;

if (preg_match('|^admin(/.*)|', $path, $matches)) {
$path = 'config'. $matches[1];
}
if ($path == 'admin') {
$path = 'config';
}
if (preg_match('|^user(/.*)|', $path, $matches)) {
$path = 'usr'. $matches[1];
}
if ($path == 'user') {
$path = 'usr';
}
}

function custom_url_rewrite_inbound(&$result, $path, $path_language) {
global
$user;



if (preg_match('|^config(/.*)|', $path, $matches)) {
$result = 'admin'. $matches[1];
}
if ($path == 'config') {
$result = 'admin';
}
if (preg_match('|^usr(/.*)|', $path, $matches)) {
$result = 'user'. $matches[1];
}
if ($path == 'usr') {
$result = 'user';
}

if ($path == 'admin') {
$result = '404';
}

if (preg_match('|^admin(/.*)|', $path, $matches)) {
$result = '404';
}
}

原文地址:https://www.cnblogs.com/davidhhuan/p/1822415.html