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

[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(

&#039;items&#039;=&gt;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)


),

)); ?>

[/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]

Where does admin.php come from ?

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

It uses the admin config file,

[pre]

<?php

// change the following paths if necessary

$yii=dirname(FILE).'/…/yii-1.0.5.r1018/framework/yii.php';

$config=dirname(FILE).'/protected/admin/config/main.php';

// remove the following line when in production mode

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

require_once($yii);

Yii::createWebApplication($config)->run();

[/pre]

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 admin.site 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.