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 7581391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:11:28+00:00 2026-05-30T18:11:28+00:00

I created a module and there exists a default controller inside that. Now I

  • 0

I created a module and there exists a default controller inside that. Now I can access the index action (default action) in the default controller like /mymodule/. For all other action i need to specify the controller id in the url like /mymodule/default/register/ . I would like to know is it possible to eliminate the controller id from url for the default controller in a module.

I need to set url rule like this:

before beautify : www.example.com/index.php?r=mymodule/default/action/

after beautify : www.example.com/mymodule/action/

Note: I want this to happen only for the default controller.

Thanks

  • 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-05-30T18:11:29+00:00Added an answer on May 30, 2026 at 6:11 pm

    This is a little tricky because the action part might be considered as a controller or you might be pointing to an existing controller. But you can get away with this by using a Custom URL Rule Class. Here’s an example (I tested it and it seems to work well):

    class CustomURLRule extends CBaseUrlRule
    {
      const MODULE = 'mymodule';
      const DEFAULT_CONTROLLER = 'default';
    
      public function parseUrl($manager, $request, $pathInfo, $rawPathInfo)
      {
        if (preg_match('%^(\w+)(/(\w+))?$%', $pathInfo, $matches)) {
          // Make sure the url has 2 or more segments (e.g. mymodule/action)
          // and the path is under our target module. 
          if (count($matches) != 4 || !isset($matches[1]) || !isset($matches[3]) || $matches[1] != self::MODULE)
            return false;
    
          // check first if the route already exists
          if (($controller = Yii::app()->createController($pathInfo))) {
            // Route exists, don't handle it since it is probably pointing to another controller
            // besides the default.
            return false;
          } else {
            // Route does not exist, return our new path using the default controller.
            $path = $matches[1] . '/' . self::DEFAULT_CONTROLLER . '/' . $matches[3];
            return $path;
          }
        }
        return false;
      }
    
      public function createUrl($manager, $route, $params, $ampersand)
      {
        // @todo: implement
        return false;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a Python module that creates and populates several SQLite tables. Now,
I'm wondering if there exists a python module that would allow me to do
I created module in netBean platform, then I created window component there, and I
I have an executable module created by third party. I would like to inject
I have created a multi module maven project. Now I have shared the project
Is there some restrictions of access to store configuration during installation of custom module
I've created a module that has its own table faces . Also, the module
In Perl there is a very handy module, Term::VT102, which allows you to create
I created module for admin specific operations. I don't want to write the same
i have created a module with this among others this function in it: <?php

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.