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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:05:03+00:00 2026-06-11T12:05:03+00:00

What i am trying to do is to create a custom rule in Yii

  • 0

What i am trying to do is to create a custom rule in Yii for URL management.

The general URL rules are set in main.php

    'urlManager'=>array(
        'urlFormat'=>'path',
                    'showScriptName'=>false,
        'rules'=>array(
            '<controller:\w+>'=>'<controller>/index',
                            '<controller:\w+>/<id:\d+>'=>'<controller>/view',
            '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
            '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
        ),

the .htaccess file is also set like

RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d


# otherwise forward it to index.php
RewriteRule . index.php

so i have URLs in the form

local/cp/xyz/create

Now i have a custom controller for which the current URL is like

local/cp/xyz/create/abc

what i want is

local/cp/abc/create

  • 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-11T12:05:04+00:00Added an answer on June 11, 2026 at 12:05 pm

    Assuming ‘local/cp’ is your application url, ‘xyz’ is the controller and ‘abc’ is some kind of variable (I’ll call it myVar), you’d need a rule like so:

    '<myVar:\w+>/<action:\w+>'=>'xyz/<action>',
    

    or

    '<myVar:\w+>/create'=>'xyz/create',
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a custom delete rule on a relationship between a parent
I'm trying to create custom URLs for my site's users: www.mysite.com/user1 If I set
I'm trying to create a custom rule that flags up the use of return
I am trying to create custom function for Main Nav menu where I can
I'm trying to create a custom validation rule for when a checkbox is checked,
I'm trying to create custom view that draws image downloaded from Url. The code
I'm trying to create a custom Checkstyle rule which will flag as an error
I am trying to create custom array indexed from 1 using subscript operator. Getting
Im trying to create a custom version of the RequiredAttribute to replace the built
I'm trying to create a custom TabItem that is dynamically added to a TabControl

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.