[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 :

 

ContractedBlock.gif ExpandedBlockStart.gif 代码
 
   
/**
*
* 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 ';
}
}

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值