Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8148735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:42:16+00:00 2026-06-06T14:42:16+00:00

See the following code of the <?php class DefaultController extends Controller { public function

  • 0

See the following code of the

<?php

class DefaultController extends Controller
{

    public function actionIndex()
    {
        $this->render('index');
    }

    /**
     * Displays the login page
     */
    public function actionLogin()
    {
        $model = new LoginForm;

        // collect user input data
        if (isset($_POST['LoginForm']))
        {
            $model->attributes = $_POST['LoginForm'];
            // validate user input and redirect to the previous page if valid
            if ($model->validate() && $model->login())
                $this->redirect(Yii::app()->user->returnUrl);
        }
        // display the login form
        $this->render('login', array('model' => $model));
    }

    public function filters()
    {
        return array(
            'accessControl',
        );
    }

    public function accessRules()
    {
        return array(
            array('allow', // allow all users to perform the 'login' action
                'actions' => array('login'),
                'users' => array('*'),
            ),
            array('allow', // allow the admin user to perform everything
                'actions' => array('*'),
                'users' => array('@'),
            ),
            array('deny', // deny all users
                'users' => array('*'),
            ),
        );
    }

}

The problem is, when I go to my module: /?r=admin I am redirected to /?r=site/index my default site controller.

How can this happen?

Edit: (added AdminModule)

<?php

class AdminModule extends CWebModule
{

    public function init()
    {
        // this method is called when the module is being created
        // you may place code here to customize the module or the application
        // import the module-level models and components
        $this->setImport(array(
            'admin.models.*',
            'admin.components.*',
        ));

        $this->setComponents(array(
            'user' => array(
                'loginUrl' => Yii::app()->createUrl('admin/default/login'),
            )
        ));
    }

    public function beforeControllerAction($controller, $action)
    {
        if (parent::beforeControllerAction($controller, $action))
        {
            // this method is called before any module controller action is performed
            // you may place customized code here

            return true;
        }
        else
            return false;
    }

}

As you see I added loginUrl via setComponents, but that does also not work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:42:18+00:00Added an answer on June 6, 2026 at 2:42 pm

    If you don’t have a logged in user the access control filter would kick in and redirect you to “home”. The only action you’re allowed to perform on the controller is “login”, so index is part of the denied actions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in a controller: <?php class Student extends CI_Controller {
See following code with resides in fillowing directory mypack.pack1 package mypack.pack1; public class myclass
I'm using SQLite3, and the SQLite3 class that's built into PHP. The following code
I am a newbie at PHP; today I see some code as the following
I have the following code in my zf2 controller: <?php namespace Accounting\Controller; use Zend\Mvc\Controller\ActionController,
What does the dollar sign mean in PHP? I have this code: <?php class
Somewhere in my code I have: class aclass { ... function amethod() { $this->dom
I am wondering if PHP will re-use the Parent class. With the following code:
How can I implement cross browser opacity gradient (not color gradient)? See following code:
Please see the following code: List list = Collections.synchronizedList(new ArrayList()); // ... synchronized (list)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.