zoukankan      html  css  js  c++  java
  • [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';
    }
    }

  • 相关阅读:
    模块化
    ES6中的let
    ES6中的块级作用域
    Mobile 移动端
    H5离线缓存
    nginx 配置步骤
    虚拟路径的配置
    Apache和php的相关配置
    TCP/IP协议
    PHP中的文件操作
  • 原文地址:https://www.cnblogs.com/davidhhuan/p/1822415.html
Copyright © 2011-2022 走看看