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

  • Home
  • SEARCH
  • 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 9159773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:34:30+00:00 2026-06-17T13:34:30+00:00

I would like to disable direct access to a Controller/Action in the Yii Framework

  • 0

I would like to disable direct access to a Controller/Action in the Yii Framework, for example login/get, and only be accessible if routed to through CUrlManager.

In my configuration I am routing requests for login to login/get and login/post depending on the HTTP method:

'urlManager' => array(
    'urlFormat' => 'path',
    'showScriptName' => false,
    'caseSensitive' => false,
    'rules' => array(
        // Rewrite GET requests of "login" to "login/get", and POST requests to "login/post".
        array('login/post', 'pattern' => 'login', 'caseSensitive' => false, 'verb' => 'POST'),
        array('login/get',  'pattern' => 'login', 'caseSensitive' => false, 'verb' => 'GET'),
    ),
),

Is there any configuration setting to disallow requests to login/get and login/post, or would the best way be to route those requests to somewhere such as error/404? For example:

array('error/404',  'pattern' => 'login/(get|post)(/.*)?')
  • 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-17T13:34:31+00:00Added an answer on June 17, 2026 at 1:34 pm

    Well your own solutions works just fine,
    the UrlManager requests rules from top to bottom, so it will try the GET/POST first

    so the full answer would be

    'rules' => array(
        // Rewrite GET requests of "login" to "login/get", and POST requests to "login/post".
        array('login/post', 'pattern' => 'login', 'caseSensitive' => false, 'verb' => 'POST'),
        array('login/get',  'pattern' => 'login', 'caseSensitive' => false, 'verb' => 'GET'),
        'login/post'=>'error/404',
        'login/get'=>'error/404',
    ),
    

    you can probably just use the rule you gave with regex

    array('error/404',  'pattern' => 'login/(get|post)(/.*)?'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to disable the parent windows access of scrollbars when the fancybox
I would like to disable the Action Center messages in Windows. I know where
I would like to know how I can disable webdav access to my plone4
I would like to disable a JQuery function ONLY in IE7. What would be
I would like to disable address space layout randomization (ASLR) on my system (Ubuntu
I would like to disable the backspace key (keycode 8) for any element except
I would like to disable displaying of the content of the window when resizing,
This post identifies a feature that I would like to disable. Current numpy behavior:
Ok, let's say that I have a button and I would like to enable/disable
I would like to know how do I disable the Showcontrols options for HTML5

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.