如何保护joomla管理员文件夹?

时间:2012-01-27 10:33:39

标签: joomla1.6

的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也可访问

3 个答案:

答案 0 :(得分:5)

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

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

/* Block access to administrator
 --------------------------------------------- */
$user =& JFactory::getUser();
$secretkey = 'mysecretkey';
$redirectto = 'location: http://www.mysite.com';
$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); }
}
/* --------------------------------------------- */

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

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

我在页面上再解释一下: http://developer.infoymas.com/jooma/protect-your-joomla-administrator-folder/

答案 1 :(得分:3)

答案 2 :(得分:1)

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

您可以使用此保护您的管理员登录。 这是非常好的延伸。

相关问题