PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, March 8, 2022

[FIXED] Yii framework urlManager rewrite rules

 March 08, 2022     yii     No comments   

Issue

I have a url that looks like this:

<controller>/<action>/param/value

and I want it to like something like this:

param/value

How can it be achieved?

I tried this rule but not sure if it's ok (controller is account and action is index).

'user/<user:.*>' => 'account/index/user/test'

Solution

If I uderstand your question correctly, you want to handle URL's like this:

mysite.domain/user/username123

And call actionIndex in AccountController with param User, which (in this case) equals "username123"

In this case you can try the rule below:

'user/<user:.*>' => 'account/index/<user>'

But maybe you will need to change the declaration if your action:

function actionIndex($user){
    // code
}


Answered By - Apfel
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing