access problem, why is it looking for site/login?

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

















… all the normal stuff, too …


My config is like this, where it merges the admin stuff with the normal stuff:




Yii::setPathOfAlias('admin', $admin);

return CMap::mergeArray(



        'basePath' => $frontend,

        'name'=>'Admin App',


        'controllerPath' => $admin.'/controllers',

        'viewPath' => $admin.'/views',

        'runtimePath' => $admin.'/runtime',

        'import' => array(









In my layout I have this menu widget:


<?php $this->widget('application.components.MainMenu',array(


	array(&#039;label&#039;=&gt;&#039;Admin Home&#039;, &#039;url&#039;=&gt;array(&#039;/admin/index&#039;)),

	array(&#039;label&#039;=&gt;&#039;Login&#039;, &#039;url&#039;=&gt;array(&#039;/admin/login&#039;), &#039;visible&#039;=&gt;Yii::app()-&gt;user-&gt;isGuest),

	array(&#039;label&#039;=&gt;&#039;Logout&#039;, &#039;url&#039;=&gt;array(&#039;/logout&#039;), &#039;visible&#039;=&gt;!Yii::app()-&gt;user-&gt;isGuest)


)); ?>


In my AdminController, I have the following:

[pre]public function filters()


        return array(




    public function accessRules()


        return array(


                'actions'=>array('index', 'admin/login'),








Where does admin.php come from ?

admin.php sits next to index.php in the localhost doc root.

It uses the admin config file,



// change the following paths if necessary



// remove the following line when in production mode

defined('YII_DEBUG') or define('YII_DEBUG',true);




Check your config/main.php file, you can define sth like:

Site/login is probably the default login page.

You might have deleted SiteController or renamed it, and therefore you need to change the admin config file.

I would reccomend agains using multiple index files and multiple config files, unless you really need it.

You would probably be better off adjusting some apache rules for the admin backend and create a seperate app for the admin backend in a different folder

have something in the public directory like

admin (folder with admin backend) with apache pointing to something like site/admin/

public (folder with the general public site)

you could then still have both point to the same framework and protected folder with both the admin and general stuff in there.

You'd then just need to configure the admin index to load a different config file and also setup some admin specific layouts and views.

If you can do subdomains you could even tell apache that goes to the site/admin directory.

I was trying to get something like the cookbook (how to configure directories for a frontend & backend) http://www.yiiframew…oc/cookbook/33/ to work and (managed config in diff modes) http://www.yiiframew…c/cookbook/32/. The front end is a sanitized web application view of the data, while the back end (admin) would be more like the code generated by the CRUD tool.

Looks like you can only specify the loginURL once in the config files. Specifying it in the admin config gives me CWebUser is read only. So, you cannot have two different login pages.