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

Tuesday, March 8, 2022

[FIXED] Yii url manager only ID in url

 March 08, 2022     controller, url, url-rewriting, yii     No comments   

Issue

i have in YII for example domain: www.example.com/product-url-1234

how to set rules in urlManager and how to use controller/action/id


Solution

If you want to use this url www.example.eu/product-url-1234

and suppose 'index' is the name of the action of the 'user' controller that will handle the request

Then create a rule like

'<id:.*?>'=>'user/index'

Now if you will use Yii::app()->createUrl('user/index',array('id'=>'product-url-1234'))

then it will give you the desired result.

And if you Visit this Url, User/Index will handle the request.



Answered By - Let me see
  • 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