dongyuan1160 2014-07-28 10:38
浏览 14
已采纳

美化Yii网址

I have URL like below:

hbbh/object/category/id/4/name/category_name/gId/3/group/group_name

And I want to change it to something like below:

hbbh/object/category/category_name/group_name

Also I added below rule to urlManager rules:

'<_c:(object|auction)>/<_a:(category)>/<name:\w+>/<group:\w+>' => '<_c>/<_a>',

The URL generated after these codes is:

hbbh/object/category/digital_suplies/mobile?id=2&gId=20

Now is there anyway to remove ?id=2&gId=20 at the end of URL? Any suggestion will be apreciated Thanks in advance

  • 写回答

1条回答 默认 最新

  • dongye3917 2015-03-06 10:58
    关注

    Unfortunately there isn't such appropriate capability. The best way is format it, to be sound good.
    for example we can change it to this format:

    hbbh/object/category/digital_suplies-2/mobile-20  
    

    By changing urlManager as below:

    '<_c:(object|auction)>/<_a:(category)>/<name:\w+>-<cid:\d+>/
                           <group:\w+>-<gid:\d+>' => '<_c>/<_a>',
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分