Yii Framework Forum: Show Only Params In Url: Url Rewriting - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Show Only Params In Url: Url Rewriting

#1 User is offline   piyush.bulandi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 19-February 14

Posted 18 June 2014 - 06:31 AM

Hi Guys,

I have been trying the following rule to remove all three 'module name' ,'controller', 'action' and showing only params instead:

'/<country:\w+>/<trip:\w+>/<poi:\w+>' => 'module/detail/index/'


It works fine. But whenever url from other module like 'other-module/controller/action' is called, rule is activated. Is there anyway to implement the rule inside a module or for one module only?

Many thanks in advance
0

#2 User is offline   Kartik V 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 626
  • Joined: 29-August 12

Posted 18 June 2014 - 06:42 AM

How will the system know, for which module, controller, and action should the url be rewritten - if you totally skip these?

IMO.. you cannot plainly skip the module, controller and action - else you will face the problem like you have now.

An option could be to have a shorter but unique alias replacing each of them.

Example:
'm1/d1/<country:\w+>/<trip:\w+>/<poi:\w+>' => 'module1/detail1/index/'
'm2/d2/<country:\w+>/<trip:\w+>/<poi:\w+>' => 'module2/detail2/index/'

0

#3 User is offline   piyush.bulandi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 19-February 14

Posted 19 June 2014 - 01:02 AM

View PostKartik V, on 18 June 2014 - 06:42 AM, said:

How will the system know, for which module, controller, and action should the url be rewritten - if you totally skip these?

IMO.. you cannot plainly skip the module, controller and action - else you will face the problem like you have now.

An option could be to have a shorter but unique alias replacing each of them.

Example:
'm1/d1/<country:\w+>/<trip:\w+>/<poi:\w+>' => 'module1/detail1/index/'
'm2/d2/<country:\w+>/<trip:\w+>/<poi:\w+>' => 'module2/detail2/index/'




Thanks for the reply. It was helpful. I have one more query. Can we show the parameter names in url but not the parameter values? However, I should be able to get parameter values.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users