【问题标题】:how to protect joomla administrator folder?如何保护 joomla 管理员文件夹?
【发布时间】:2012-02-20 08:43:29
【问题描述】:

index.php

$admin_cookie_code="1234567890";
setcookie("JoomlaAdminSession",$admin_cookie_code,0,"/");
header("Location: /administrator/index.php");

.htaccess 文件

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/administrator
RewriteCond %{HTTP_COOKIE} !JoomlaAdminSession=1234567890
RewriteRule .* - [L,F]

我使用了此代码,但它不起作用... 页面将被重定向到管理员,但 www.domain.com/administrator 也可以访问

【问题讨论】:

    标签: joomla1.6


    【解决方案1】:

    我厌倦了为这个问题寻找答案,只是制作了一个 PHP 代码,如果访问者没有安全密钥或作为注册用户进入 /administration 文件夹,它将重定向:

    只需将此代码放在管理文件夹 (/administration/index.php) 中 index.php 文件末尾的“echo”指令之前:

    /* Block access to administrator
     --------------------------------------------- */
    $user =& JFactory::getUser();
    $secretkey = 'mysecretkey';
    $redirectto = 'location: yourdomainurlhere';
    $usertype = 'Registered';
    
    //Check if the user is not logged in or if is not a super user:
    if ($user->guest || (!$user->guest && $user->usertype != $usertype) ) {
     //Check if the secret key is present on the url:
     if (@$_GET['access'] != $secretkey) { header($redirectto); }
    }
    /* --------------------------------------------- */
    

    之后您将只能使用以下方式访问您的网站: mysite.com/administrator/?access=mysecretkey

    在 Joomla 1.5 和 Jooma 2.5 上测试,两者都运行良好。

    我在我的页面上稍微解释一下: https://www.infoeplus.com/protect-your-joomla-administrator-folder/

    【讨论】:

      【解决方案2】:
      【解决方案3】:

      http://extensions.joomla.org/extensions/access-a-security/site-security/login-protection

      您可以使用它来保护您的管理员登录。 这真的是很好的扩展。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-11-09
        • 1970-01-01
        • 2016-06-02
        • 1970-01-01
        相关资源
        最近更新 更多