I have an admin area on my site. I set the menu widget to load my admin/login, but when I click the link to localhost/admin.php?r=admin/login, I get Page Not Found for localhost/admin.php?r=site/login
I think it's an access issue. If I remove the access rules from my controller, I see a login form.
If I want a guest user to have access to index and login only, what should the rules be for this config? And why does it request site/login instead of admin/login when there is a permissions issue?
I have an application directory like
[pre]
protected/
admin/
components/
config/
main.php
controllers/
AdminController.php
modules/
runtime/
views/
admin/
index.php
login.php
layouts/
main.php
… all the normal stuff, too …
[/pre]
My config is like this, where it merges the admin stuff with the normal stuff:
[pre]
$admin=dirname(dirname(FILE));
$frontend=dirname($admin);
Yii::setPathOfAlias('admin', $admin);
return CMap::mergeArray(
require($frontend.'/config/main.php'),
array(
'basePath' => $frontend,
'name'=>'Admin App',
'defaultController'=>'admin',
'controllerPath' => $admin.'/controllers',
'viewPath' => $admin.'/views',
'runtimePath' => $admin.'/runtime',
'import' => array(
'application.admin.models.*',
'application.admin.components.*',
'application.models.*',
'application.components.*',
),
)
);
[/pre]
In my layout I have this menu widget:
[pre]
…
<?php $this->widget('application.components.MainMenu',array(
'items'=>array(
array('label'=>'Admin Home', 'url'=>array('/admin/index')),
array('label'=>'Login', 'url'=>array('/admin/login'), 'visible'=>Yii::app()->user->isGuest),
array('label'=>'Logout', 'url'=>array('/logout'), 'visible'=>!Yii::app()->user->isGuest)
),
)); ?>
…
[/pre]
In my AdminController, I have the following:
[pre]public function filters()
{
return array(
'accessControl',
);
}
public function accessRules()
{
return array(
array('allow',
'actions'=>array('index', 'admin/login'),
'users'=>array('?'),
),
array('deny',
'users'=>array('*'),
),
);
}[/pre]